Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to interpolate to get two values for one variable?

Asked by KH

KH (view profile)

on 4 Dec 2012

I have a graph which is ascending in the beginning and will descend afterwards.

Let's say my y-axis is Y, and x-axis is X,

for a certain Y value, it will give two values on the x-axis.

say in this case i set Y to a value of 20, but it only gives me one X value, which is the latter value when the graph is in its descending portion. How do I get the X value for the initial ascending part of the graph?

I did something like this: interp1(Y,X,20)

Kindly advice.. Thanks!

0 Comments

KH

KH (view profile)

Products

No products are associated with this question.

1 Answer

Answer by John Petersen

John Petersen (view profile)

on 4 Dec 2012

Use the same index for each parameter. If you want to know the values of X for a given value of Y,

yind = (Y==yvalue);  
xvalues = X(yind);  % values of x that correspond to yvalue

0 Comments

John Petersen

John Petersen (view profile)

Contact us