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:
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');