二元函数拟合怎样效果最好?。

11 Ansichten (letzte 30 Tage)
腾龙娱乐开户网址(tlyf002 .com)
clear,clc
x1=[1.2:.1:1.7]';
x2=[1000        5000        7500       10000        15000];
y=[14964       13166        14235      15550        19200
   13479       13479        13090      14235        17014
   13747       13747        12750      13139        14991
   13917       13917        13019      12553        13967
   14065       14065        13386      12821        13188
   14306       14306        13578      13040        12728];
n1=length(x1);n2=length(x2);
x1=x1*ones(1,n2);x1=x1(:);
x2=ones(n1,1)*x2;x2=x2(:);
y=y(:); X=[x1,x2]; n=length(y);
str=num2str([1:n]');
fx1=@(b,x1,x2)(b(1)+b(2)*x2+b(3)*x2.^2+b(4)*x1.*x2+b(5)*x1.^3+b(6)*x2.^3+b(7)*x1.^4+b(8)*x2.^4+b(9)*x1.*x2.^3+b(10)*x1.^2.*x2.^2+b(11)*x1.^5+b(12)*x2.^5)./(1+b(13)*exp(b(14)*x1+b(15)*x2+b(16)*x1.^2+b(17)*x2.^2+b(18)*x1.*x2));
fx2=@(b,X)(b(1)+b(2)*X(:,2)+b(3)*X(:,2).^2+b(4)*X(:,1).*X(:,2)+b(5)*X(:,1).^3+b(6)*X(:,2).^3+b(7)*X(:,1).^4+b(8)*X(:,2).^4+b(9)*X(:,1).*X(:,2).^3+b(10)*X(:,1).^2.*X(:,2).^2+b(11)*X(:,1).^5+b(12)*X(:,2).^5)./(1+b(13)*exp(b(14)*X(:,1)+b(15)*X(:,2)+b(16)*X(:,1).^2+b(17)*X(:,2).^2+b(18)*X(:,1).*X(:,2)));
b=[345.45 -191.53 41.80 -2.6793  83.3156  -4.4545  -156.1311 0.2333  -0.0086582 0.251804  81.565  -0.0048047  989422  -146.607  4.003 95.35213571  -0.25589 2.752];
for l=1:5
    b=lsqcurvefit(fx2,b,X,y);
    b=nlinfit(X,y,fx2,b);
end
b
figure(1),clf
plot3(x1,x2,y,'o')
stem3(x1,x2,y,'filled')
text(x1,x2,y+.01,str)
hold on
[x11,x22]=meshgrid(min(x1):range(x1)/80:max(x1),min(x2):range(x2)/80:max(x2));
yhat=fx1(b,x11,x22);
surf(x11,x22,yhat)
shading interp
alpha(.8)
axis tight
xlabel('α');ylabel('C'),zlabel('V1')
SSy=var(y)*(n-1)
y1=fx1(b,x1,x2);
RSS=(y-y1)'*(y-y1)
rsquare=(SSy-RSS)/SSy
MSe=RSS/(n-length(b))
想通过matlab拟合得到二元函数y=f(x1,x2)的表达式,但是这里面18组初始的b值是参考别人的模板,因为是用另外的数据生成的,请问怎么用程序实现我这组数据里面的18组初始b值呢?比如用nlinfit,或者cftool,请大佬多多指教!:handshake 之前用cftool拟合后得到的poly23多项式函数的函数值域与已知数据相差几个数量级,函数表达式明显是错误的。

Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!