天天看點

matlab已知a(x)=,matlab拟合二個未知變量.已知A=x-10*y*lgB;

共回答了24個問題采納率:87.5%

A=[1,2,3,4,5,6,7,8,9,10]; B=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];

>> fun=inline('x(1)-10*x(2)*log10(B)','x','B'); %log10(B),10為底的常用對數

>> [x,resnorm,residual,exitflag]=lsqcurvefit(fun,[0.1 1],B,A)

Local minimum found.

Optimization completed because the size of the gradient is less thanthe default value of the function tolerance.

x =

8.6137 -0.9051

resnorm =

7.7829

residual =

Columns 1 through 7

-1.4371 0.2875 0.8812 1.0120 0.8891 0.6058 0.2117

Columns 8 through 10

-0.2634 -0.8005 -1.3863

exitflag =

1

%exitflag =1,最優解

拟合的最優x和y值:x= 8.6137 y=-0.9051

1年前

追問

4

matlab已知a(x)=,matlab拟合二個未知變量.已知A=x-10*y*lgB;

您好,我的方法算的y和你的y差個負号,甯能幫忙看看哪裡不對嗎?最佳給您! clc; A=[1;2;3;4;5;6;7;8;9;10]; B=[0.1;0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9;1]; B=10*log10(B); X=[ones(10,1),B]; [b,bint,r,rint,stats]=regress(A,X) fprintf('經驗公式中的系數x,y分别為%f,%fn',b(1),b(2)); 經驗公式中的系數x,y分别為8.613684,0.905078

matlab已知a(x)=,matlab拟合二個未知變量.已知A=x-10*y*lgB;

用Matlab的工具箱,得到的結果與上面的的結果是一樣的。 General model: f(B) = a-10*b*log10(B) Coefficients (with 95% confidence bounds): a = 8.614 (7.523, 9.704) b = -0.9051 (-1.143, -0.6669) Goodness of fit: SSE: 7.783 R-square: 0.9057 Adjusted R-square: 0.8939 RMSE: 0.9863