Tricks in MATLAB

From Computational Biophysics and Materials Science Group
Revision as of 18:24, 28 November 2014 by Kevin (Talk | contribs) (Created page with "==Quick fitting== http://www.mathworks.com/help/matlab/ref/polyfit.html a= 1:0.1:10; p = polyfit(a,exp(a),5); % Fits a fifth degree polynomial to exp(a) in the Least square...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Quick fitting

http://www.mathworks.com/help/matlab/ref/polyfit.html

a= 1:0.1:10;
p = polyfit(a,exp(a),5); % Fits a fifth degree polynomial to exp(a) in the Least squares sense
v = polyval(p,a);
plot(a,v,a,exp(a)) % You will see the difference.