Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经有了使用折线图的 xy 图。让我烦恼的是,如果我给出 x 的值,我怎么能要求 matlab 给我 y 的值。也就是说,当我在图中的行中给出 x 时,y 的对应值。
我认为你想要做的是插值。
假设您用于绘图的 x 和 y 值分别存储在xData和yData中。
xData
yData
然后,您找到与使用INTERP1y的值对应的值x
y
x
y = interp1(xData,yData,x);
默认情况下,interp1线性插值,也就是说,它返回的值就像图中的点由直线连接一样。如果你想要更平滑的插值,你会使用
interp1
y = interp1(xData,yData,x,'cubic');