Have x find y

1 次查看(过去 30 天)
androSLO
androSLO 2014-1-18
回答: androSLO 2014-1-19
Hello,
I have one problem which i can't solve.
I have x = [...], y1=[...], y2=[..] And i have made plot in one graph. Now i want with specific X (is 230) find y1 and y2 on graph and write it out that i can know which value is y1 and y2 on this x.
Thanks in advance. Regards, Andrej

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-1-18
x=0:0.1:10;
y1=cos(x);
y2=sin(x);
x1=2.234
y11=interp1(x,y1,x1)
Y21=interp1(x,y2,x1)

更多回答(3 个)

Image Analyst
Image Analyst 2014-1-18
You can use spline() or polyfit() to get the value at "in between" locations.
  1 个评论
Image Analyst
Image Analyst 2014-1-18
Actually it's easier to just do what Azzi showed you.

请先登录,再进行评论。


androSLO
androSLO 2014-1-19
It doesn't go.. I have this form done till now:
y1=[52.50 48.75 30 20 13.75 10 7.50 5 3]; x=[253 241 207 184 161.1 137.8 114.6 92.3 68.8]; y2=[0.683 0.586 0.347 0.237 0.157 0.117 0.092 0.075 0.060];
%figure 1
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot'); set(get(AX(1),'Ylabel'),'String','P_1_0 [W]') set(get(AX(2),'Ylabel'),'String','I_1_0 [A]') xlabel('U_1_0 [V]') grid on
And i have known X=230, and have to find y1 and y2 on this X..
  2 个评论
Amit
Amit 2014-1-19
Azzi code was generalized. It will work for your case as well.
x1 = 230;
y11=interp1(x,y1,x1)
Y21=interp1(x,y2,x1)
y1l and y2l are interpolated values at x = 230.
androSLO
androSLO 2014-1-19
Thank you it works now :) Thank you very muuchh :)

请先登录,再进行评论。


androSLO
androSLO 2014-1-19
Now i have another question.. I have 3 y axes and one x axis. I have one y axis on right side and two on left side.. I want that they all three are on right side and one next to the other?

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by