polynomials fitting

2 Ansichten (letzte 30 Tage)
SAM alimostafa
SAM alimostafa am 25 Mai 2011
hi if i want to use polyfit and polyval for two vectores x and y do they must be at the same size?? in my case x is greater than y by one and i want to predict the value of y at that point wt can i do????

Akzeptierte Antwort

Ben Mitch
Ben Mitch am 25 Mai 2011
say you have
x = [1 2 3 4];
y = [8 12 16];
then you can fit a polynomial to the region you have data for (the first three samples) using
p = polyfit(x(1:length(y)), y, 1);
and estimate all the samples using
y_est = polyval(p, x);
or just the ones you don't have data for using
y_est = polyval(p, x(length(y)+1:end));

Weitere Antworten (0)

Kategorien

Mehr zu Polynomials finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by