views:

20

answers:

1

I already have my xy graph using the line graph. What troubles me is how can I ask matlab to give me the value of y if I give the value of x. That is, the corresponding value of y when I give x in the line I have in the graph.

+1  A: 

What I think you want to do is interpolation.

Say your x and y values that you used for plotting are stored in xData and yData, respectively.

Then, you find a value y that corresponds to a value x using INTERP1

y = interp1(xData,yData,x);

By default, interp1 interpolates linearly, that is, it returns the values as if the dots in the plot were connected by straight lines. If you want a smoother interpolation, you'd use

y = interp1(xData,yData,x,'cubic');
Jonas