How can I graph several points from a table and extrapolate a curve?

1 次查看(过去 30 天)
I'm somewhat new to MATLAB, although I used it in school. I have a table of x and y-values, and want to plot the points on a graph and then extrapolate a linear curve. Can someone help explain how to do this? I am used to graphing with equations, this is sort of the opposite way around.

采纳的回答

dpb
dpb 2013-12-9
Well, poly[fit|val] are "all in Matlab"...
dat=[1500,200; 2500,259; 4530,1980];
plot(dat(:,1),dat(:,2))
p=polyfit(dat(:,1),dat(:,2),1);
yhat=polyval(p,[1000 5000]);
hold on
plot([1000 5000],yhat)

更多回答(1 个)

dpb
dpb 2013-12-9
A) doc plot
B) doc polyfit % and polyval
  1 个评论
Stephen
Stephen 2013-12-9
Thank you. If I'm looking more to do it all in matlab, then, say I'm starting at a data range like
x=1000:10:5000; y=0:.5:2000;
and I want to plot several points, say (1500,200) (2500,259) and (4530,1980) and then apply the polyfit % and polyval functions. How would I accomplish something like that?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by