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
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 19일
androSLO commented
How to do that?

댓글을 달려면 로그인하십시오.

채택된 답변

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