matlab的nlinfit问题a=[1,1,1];>> r=15:49;>> b1=[ 0.000010000 0.000160000 0.000840000 0.002390000 0.004150000 0.010370000 0.019870000 0.028860000 0.044920000 0.055200000 0.054620000 0.059010000 0.059650000 0.068670000 0.055330000 0.040070000 0.03252
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 12:30:46
matlab的nlinfit问题a=[1,1,1];>> r=15:49;>> b1=[ 0.000010000 0.000160000 0.000840000 0.002390000 0.004150000 0.010370000 0.019870000 0.028860000 0.044920000 0.055200000 0.054620000 0.059010000 0.059650000 0.068670000 0.055330000 0.040070000 0.03252
matlab的nlinfit问题
a=[1,1,1];
>> r=15:49;
>> b1=[ 0.000010000 0.000160000 0.000840000 0.002390000 0.004150000 0.010370000 0.019870000 0.028860000 0.044920000 0.055200000 0.054620000 0.059010000 0.059650000 0.068670000 0.055330000 0.040070000 0.032520000 0.025670000 0.018140000 0.014650000 0.011940000 0.009660000 0.008380000 0.006950000 0.005590000 0.005320000 0.004050000 0.004600000 0.003400000 0.003210000 0.003420000 0.002950000 0.003690000 0.003750000 0.002660000 ];
>> fun=inline('1/sqrt(2*pi*a(2).^2)*exp(-1/2*(log(r-15)-a(1)).^2/a(2)^2)*a(3)','r','a');
>> ae=nlinfit(t,c,f,a);
程序显示错误:Error using ==> nlinfit at 127
MODELFUN should return a vector of fitted values the same length as Y.
然后我简化方程fun=inline('exp(log(r))','r','a'),还是那个错,
r,b1都是35个
matlab的nlinfit问题a=[1,1,1];>> r=15:49;>> b1=[ 0.000010000 0.000160000 0.000840000 0.002390000 0.004150000 0.010370000 0.019870000 0.028860000 0.044920000 0.055200000 0.054620000 0.059010000 0.059650000 0.068670000 0.055330000 0.040070000 0.03252
我的matlab告诉我这错.
MODELFUN must be a function that returns a vector of fitted values the same size as Y (1-by-35). The model function you
provided returned a result that was 1-by-3.
One common reason for a size mismatch is using matrix operators (*, /, ^) in your function instead of the corresponding
elementwise operators (.*, ./, .^).
如果你还不知道自己哪错了,就试试用fun=inline('exp(log(r))','a','r')再算一下(注意我给你的函数和你写的是不一样的)然后应该就知道了.