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

조회 수: 22 (최근 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 CenterFile Exchange에서 数学에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!