最小二乘法曲线拟合求系数及R平方的问题。

23 ビュー (過去 30 日間)
xohidi
xohidi 2022 年 11 月 21 日
回答済み: cijof 2022 年 11 月 21 日
方程为:y=a*x*exp(b*x)
其中y,x均已知,为一个序列的数,现在想利用最小二乘确定系数a和b,MATLAB中该如何实现呢?谢谢各位

採用された回答

cijof
cijof 2022 年 11 月 21 日
syms t
x = [0;0.4;1.2;2;2.8;3.6;4.4;5.2;6;7.2;8;9.2;10.2;11.6;12.4;13.6;14.4;15];
y = [1;0.85;0.29;-0.27;-0.53;-0.4;-0.53;-0.4;-.12;.17;.28:.15;-0.03;-0.15;-0.071;0.059;0.08;0.32;-0.015;-0.02];
f = fittype('a * cos(k*t)*exp(w*t)','independent','t','coefficients',{'a','k','w'});
cfun = fit(x,y,f)             % 显示拟合函数
xi = 0:.1:20;
yi = cfun(xi);                 
plot(x, y, 'r*', xi, yi, 'b-')
legend('样本', 'a*cos(k*t)e^{(w*t)}')
给你个例子,你可以套着做[attach]142390[/attach]
命令窗口可以看得到a k w的值

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange数学 についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!