matlab中 内部矩阵维度问题源程序为clc;clear; x=[100110120130140.1150160.1170180190.2200210.1220230240250260270280290300310320330340350360369.9380390400]; y=[1.531.551.571.591.591.611.61.61.61.591.581.441.421.41.381.361.341.311.281.261.231
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 21:13:01
matlab中 内部矩阵维度问题源程序为clc;clear; x=[100110120130140.1150160.1170180190.2200210.1220230240250260270280290300310320330340350360369.9380390400]; y=[1.531.551.571.591.591.611.61.61.61.591.581.441.421.41.381.361.341.311.281.261.231
matlab中 内部矩阵维度问题
源程序为
clc;clear;
x=[100110120130140.1150160.1170180190.2200210.1220230240250260270280290300310320330340350360369.9380390400];
y=[1.531.551.571.591.591.611.61.61.61.591.581.441.421.41.381.361.341.311.281.261.231.21.181.151.121.091.071.041.020.9920.968];
myfunc=inline('beta(1)/sqrt(x)*exp(beta(2)/x+beta(3)/(x*x))','beta','x');
beta=nlinfit(x,y,myfunc,[0 0 0]);
p1=beta(1),p2=beta(2),p3=beta(3)
%test the model
xx=min(x):max(x);
yy=p1./sqrt(x)*exp(p2./x+p3./(x^2));
plot(x,y,'o',x,yy,'r')
运行结果提示内部矩阵维度问题:
错误使用 nlinfit (line 199)Error evaluating inline model function.
原因:错误使用 inlineeval (line 14)
内联表达式出错 ==> beta(1)/sqrt(x)*exp(beta(2)/x+beta(3)/(x*x))
内部矩阵维度必须一致.
能附上正确的程序更好
matlab中 内部矩阵维度问题源程序为clc;clear; x=[100110120130140.1150160.1170180190.2200210.1220230240250260270280290300310320330340350360369.9380390400]; y=[1.531.551.571.591.591.611.61.61.61.591.581.441.421.41.381.361.341.311.281.261.231
贴的代码实在格式看不清,贴图就更好了.
x和y是多大的?比如你的inline里面的(x*x)就感觉不对,这个矩阵乘法要求X是方阵.
你也许要用.*和./代替*和/?