Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

dpb
dpb am 9 Dez. 2013
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)

Weitere Antworten (1)

dpb
dpb am 9 Dez. 2013
A) doc plot
B) doc polyfit % and polyval
  1 Kommentar
Stephen
Stephen am 9 Dez. 2013
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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by