如何根据已知数据和函数类型用matlab求解函数?

2025-04-30 02:51:57
推荐回答(1个)
回答1:

求解方法:
1、建立M文件myfun.m
function y = myfun(x)
y=a(1)*(1+(a(2)^2)*exp(x.*a(3))+cos(x)).*sqrt((1-(a(2)^2))*x)./x.^2;

2、在窗口命令中执行下列命令
>> x=[1,2,3,4,5,6,7];
>> y=[0.0183 0.0043 0.0038 0.0087 0.0211 0.0521 0.1360];
>> b=rand(1,3);
>> a=lsqcurvefit(myfun,b,x,y);
>>c=a(3)
>>b=a(2)
>>a=a(1)