matlab编程问题,已知函数表达式和数据,求表达式中的系数

2024-12-22 10:27:40
推荐回答(2个)
回答1:

t=[0.1,1.1,2.3,3.4,4.5,5.7,6.7]';
y=[0,94.0,84.0,77.0,69.0,62.0,56.0]';
ft_ = fittype('A*exp(-beta*t)*cos(w*t+phi)',...
'dependent',{'y'},'independent',{'t'},...
'coefficients',{'A', 'beta', 'phi', 'w'});
st=[-100 0.01 -pi 5]
[curve, goodness]= fit(t,y,ft_,'Startpoint',st)
figure
plot(curve,'predobs',0.95);
hold on,plot(t,y,'b*')

st =

-100.0000 0.0100 -3.1416 5.0000

curve =

General model:
curve(t) = A*exp(-beta*t)*cos(w*t+phi)
Coefficients (with 95% confidence bounds):
A = -143.8 (-219.6, -68.05)
beta = 0.135 (0.01584, 0.2541)
phi = -2.131 (-2.379, -1.883)
w = 5.394 (5.259, 5.529)

goodness =

sse: 352.1786
rsquare: 0.9377
dfe: 3
adjrsquare: 0.8754
rmse: 10.8348

回答2:

我知道一个非线性拟合的函数:lsqcurvefit,不知道对你有没有帮助,可以拟合出表达式的未知参数