Command for basic fitting
45 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I know we can use Tools -> Basic Fitting from the menu bar in the plot to generate linear or higher order equations for relationships between x and y. But it is a graphic way, if I want to draw the fitting curve by using m-script, which command should I use?
Thanks.
Y-L
0 件のコメント
採用された回答
Grzegorz Knor
2011 年 9 月 26 日
To find the coefficients of a polynomial of degree n use polyfit function.
Alternatively use the option: File -> Generate M-file, to preview the source code.
その他の回答 (1 件)
UJJWAL
2011 年 9 月 26 日
Gregorz is right. Here is a bit of an example :
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.
Happy To help
参考
カテゴリ
Help Center および File Exchange で Polynomials についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!