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

19 views (last 30 days)
xohidi
xohidi on 21 Nov 2022
Answered: cijof on 21 Nov 2022
方程为:y=a*x*exp(b*x)
其中y,x均已知,为一个序列的数,现在想利用最小二乘确定系数a和b,MATLAB中该如何实现呢?谢谢各位

Accepted Answer

cijof
cijof on 21 Nov 2022
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的值

More Answers (0)

Categories

Find more on 数学 in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!