matlab求助,nlinfit求助.clc;clearx=[0.48,0.42,0.36,0.3,0.25,0.2,0.14,0.08,0.02;5000,5000,5000,5000,5000,5000,5000,5000,5000]'y=[6.73333E-05,5.13333E-05,4.46667E-05,3.83333E-05,2.93333E-05,0.000022,1.73333E-05,0.000003,-1.66667E-06]'t2=25B=120L=500
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 21:30:44
matlab求助,nlinfit求助.clc;clearx=[0.48,0.42,0.36,0.3,0.25,0.2,0.14,0.08,0.02;5000,5000,5000,5000,5000,5000,5000,5000,5000]'y=[6.73333E-05,5.13333E-05,4.46667E-05,3.83333E-05,2.93333E-05,0.000022,1.73333E-05,0.000003,-1.66667E-06]'t2=25B=120L=500
matlab求助,nlinfit求助.
clc;clear
x=[0.48,0.42,0.36,0.3,0.25,0.2,0.14,0.08,0.02;5000,5000,5000,5000,5000,5000,5000,5000,5000]'
y=[6.73333E-05,5.13333E-05,4.46667E-05,3.83333E-05,2.93333E-05,0.000022,1.73333E-05,0.000003,-1.66667E-06]'
t2=25
B=120
L=500
f=@(b,x)(x(:,2)./(2*t2*B)-b(2)*x(:,2)/b(1)+b(2)*x(:,2)*exp(-sqrt(b(1))*L)/b(1))./(exp(sqrt(b(1))*L)-exp(-sqrt(b(1))*L))*exp(sqrt(b(1))*x(:,1))+(x(:,2)/(2*t2*B)-b(2)*x(:,2)/b(1)+b(2)*x(:,2)*exp(sqrt(b(1))*L)/b(1))./(exp(-sqrt(b(1))*L)-exp(sqrt(b(1))*L))*exp(-sqrt(b(1))*x(:,1))+b(2)*x(:,2)/b(1)
b0=[1;1]
betafit=nlinfit(x,y,f,b0)
运行时提示错误.
Error using ==> nlinfit
The model function '@(b,x)(x(:,2)/(2*t2*B)-b(2)*x(:,2)/b(1)+b(2)*x(:,2)*exp(-sqrt(b(1))*L)/b(1))./(exp(sqrt(b(1))*L)-exp(-sqrt(b(1))*L))*exp(sqrt(b(1))*x(:,1))+(x(:,2)/(2*t2*B)-b(2)*x(:,2)/b(1)+b(2)*x(:,2)*exp(sqrt(b(1))*L)/b(1))./(exp(-sqrt(b(1))*L)-exp(sqrt(b(1))*L))*exp(-sqrt(b(1))*x(:,1))+b(2)*x(:,2)/b(1)' generated the following error:
Error using ==> mtimes
Inner matrix dimensions must agree.
不知道哪里错了.
拟合函数如下:
C1=(x(:,2)./(2*t2*B)-b(2)*x(:,2)./b(1)+b(2)*x(:,2)*exp(-sqrt(b(1))*L)./b(1))./(exp(sqrt(b(1))*L)-exp(-sqrt(b(1))*L))
C2=(x(:,2)./(2*t2*B)-b(2)*x(:,2)./b(1)+b(2)*x(:,2)*exp(sqrt(b(1))*L)./b(1))./(exp(-sqrt(b(1))*L)-exp(sqrt(b(1))*L))
f=C1*exp(sqrt(b(1))*x(:,1))+C2*exp(-sqrt(b(1))*x(:,1))+b(2)*x(:,2)./b(1)
希望求解方程中的两个参数,b(1)与b(2).
matlab求助,nlinfit求助.clc;clearx=[0.48,0.42,0.36,0.3,0.25,0.2,0.14,0.08,0.02;5000,5000,5000,5000,5000,5000,5000,5000,5000]'y=[6.73333E-05,5.13333E-05,4.46667E-05,3.83333E-05,2.93333E-05,0.000022,1.73333E-05,0.000003,-1.66667E-06]'t2=25B=120L=500
错误信息是矩阵大小不统一 你仔细看看你的各个参数的大小size是否一致