matlab画图,一个图心里两条曲线,要将纵坐标为最高点纵坐标的0.707倍的两个点标识出来并求其坐标。
y=[0.078,0.182,0.285,0.380,0.479,0.594,0.695,0.788,0.886,0.979,1.049,1.103,1.174,1.224,1.290,1.351,1.393,1.440,1.462,1.475,1.472,1.451,1.416,1.378,1.325,1.269,1.209,1.162,1.100,1.042,0.997,0.941,0.849,0.734,0.641,0.533,0.434,0.329,0.231,0.132,0.056]
x1=[259.91,261.11,261.41,261.561,261.661,261.711,261.751,261.785,261.791,261.801,261.811,261.821,261.831,261.841,261.851,261.861,261.871,261.881,261.891,261.901,261.911,261.921,261.931,261.941,261.951,261.961,261.971,261.981,261.991,262.001,262.011,262.021,262.031,262.061,262.101,262.141,262.201,262.291,262.441,262.781,262.981]
y1=[0.074,0.171,0.263,0.364,0.487,0.586,0.691,0.795,0.826,0.875,0.91,0.957,1.008,1.047,1.098,1.138,1.184,1.210,1.236,1.249,1.251,1.243,1.227,1.198,1.163,1.133,1.088,1.054,1.008,0.973,0.928,0.884,0.850,0.739,0.628,0.534,0.437,0.338,0.242,0.143,0.054]
求大神解答 展开
你这个题目怎么这么复杂!希望我没理解错!
你说的找到“纵坐标为最高点纵坐标的0.707倍的两个点”
指得是比较精确的坐标值吧,不是说从你的x里找2个最接近的值吧?
要是这样,我只有崩溃了。如果要求较精确的坐标,要用到插值计算的
你参考一下:
clear all;clc;
x=[260.430,261.630,261.93,262.06,262.14,262.2,262.24,262.264,262.286,262.304,...
262.314,262.324,262.334,262.344,262.354,262.364,262.374,262.384,262.394,...
262.404,262.414,262.424,262.434,262.444,262.454,262.464,262.474,262.484,...
262.494,262.504,262.514,262.524,262.544,262.575,262.605,262.655,262.715,...
262.815,262.985,263.385,264.485];
y=[0.078,0.182,0.285,0.380,0.479,0.594,0.695,0.788,0.886,0.979,1.049,1.103,....
1.174,1.224,1.290,1.351,1.393,1.440,1.462,1.475,1.472,1.451,1.416,1.378,...
1.325,1.269,1.209,1.162,1.100,1.042,0.997,0.941,0.849,0.734,0.641,0.533,...
0.434,0.329,0.231,0.132,0.056];
x1=[259.91,261.11,261.41,261.561,261.661,261.711,261.751,261.785,261.791,...
261.801,261.811,261.821,261.831,261.841,261.851,261.861,261.871,261.881,...
261.891,261.901,261.911,261.921,261.931,261.941,261.951,261.961,261.971,...
261.981,261.991,262.001,262.011,262.021,262.031,262.061,262.101,262.141,...
262.201,262.291,262.441,262.781,262.981];
y1=[0.074,0.171,0.263,0.364,0.487,0.586,0.691,0.795,0.826,0.875,0.91,0.957,...
1.008,1.047,1.098,1.138,1.184,1.210,1.236,1.249,1.251,1.243,1.227,1.198,...
1.163,1.133,1.088,1.054,1.008,0.973,0.928,0.884,0.850,0.739,0.628,0.534,...
0.437,0.338,0.242,0.143,0.054];
xm=find(y==max(y)); %找到y的最大值对应的x的下标
xx1=x(1):0.001:x(xm); %在y最大值的左面定义一个变量xx1
xx2=x(xm+1):0.001:x(end); %在y最大值的左面定义一个变量xx2
yx1=interp1(x(1:xm),y(1:xm),xx1); %在y最大值的左面线性插值
yx2=interp1(x(xm+1:end),y(xm+1:end),xx2); %在y最大值的右面线性插值
g1=find(abs(yx1-0.707*max(y))==min(abs(yx1-0.707*max(y))));
%找到y最大值左面与y最大值的0.707倍最接近的x下标
g2=find(abs(yx2-0.707*max(y))==min(abs(yx2-0.707*max(y))));
%找到y最大值右面与y最大值的0.707倍最接近的x下标
plot(x,y);hold on;plot(x1,y1,'r');
xlabel('驱动力频率f');ylabel('输出电压Umax');
legend('无阻尼状态','有阻尼状态');
title('Umax——f关系曲线'); %这部分是你的原图
plot(xx1(g1),yx1(g1),'bo');plot(xx2(g2),yx2(g2),'bo'); %画出要求的2个点
text(261.2,0.9,['(',num2str(xx1(g1)),',',num2str(yx1(g1)),')']);
text(262.5,0.9,['(',num2str(xx2(g2)),',',num2str(yx2(g2)),')']);