求 参数 多元非线性回归。

14 views (last 30 days)
sonoy
sonoy on 17 Nov 2022
Answered: capik on 17 Nov 2022
各位大侠,我试验得到一组数据(两个自变量x1,x2,一个因变量y),已知方程,想通过回归方式求其中四个参数,能否给个程序,以前没用过MATLAB,感激不尽!
x1=[20 20 20 20 40 40 40 40 60 60 60 60];
x2=[15 30 45 60 15 30 45 60 15 30 45 60];
y=[0.06 0.076 0.183 0.284 0.37 0.19 0.371 0.556 0.812 0.938 0.296 0.644 0.96 1.522 1.813];
其中y=((x1*sin(x2)-a)^2/(2*b)+(x1.^2*cos(x2)^2*sin(c*x2))/(2*d)
x2列数据是角度值
求其中的参数a,b,c,d值。

Accepted Answer

capik
capik on 17 Nov 2022
x(:,1)=[20 20 20 20 40 40 40 40 60 60 60 60]';
x(:,2)=[15 30 45 60 15 30 45 60 15 30 45 60]';
beta0=[1 1 1 1];
y=[0.06 0.076 0.183 0.284 0.37 0.19 0.371 0.556 0.812 0.938 0.296 0.644]';
f=@(beta,x)((x(:,1).*sin(x(:,2))-beta(1)).^2/(2*beta(2))+(x(:,1).^2.*cos(x(:,2)).^2.*sin(beta(3).*x(:,2)))/(2*beta(4)));
[beta,r,j]=nlinfit(x,y,f,beta0);
beta =
1.0e+03 *
0.0094 2.8425 0.0010 1.2828
你看看结果是不是符合,另外你给的Y的维数和x不一样,我去掉了最后三个

More Answers (0)

Categories

Find more on MATLAB 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!