Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

dpb
dpb il 9 Dic 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)

Più risposte (1)

dpb
dpb il 9 Dic 2013
A) doc plot
B) doc polyfit % and polyval
  1 Commento
Stephen
Stephen il 9 Dic 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?

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by