Error using ==> mtimes Inner matrix dimensions must agree 用matlab求解时出现错误x=0:1:12;a=sqrt(10.08+0.5*sqrt(406.43+31.7*x.^2));b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x.^2));c=1./(2*cos(0.115*sqrt(5.63i*x+20.16))); y=0;f=499800*(abs(c)).^2*x*(e

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 19:03:54

Error using ==> mtimes Inner matrix dimensions must agree 用matlab求解时出现错误x=0:1:12;a=sqrt(10.08+0.5*sqrt(406.43+31.7*x.^2));b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x.^2));c=1./(2*cos(0.115*sqrt(5.63i*x+20.16))); y=0;f=499800*(abs(c)).^2*x*(e
Error using ==> mtimes Inner matrix dimensions must agree 用matlab求解时出现错误
x=0:1:12;
a=sqrt(10.08+0.5*sqrt(406.43+31.7*x.^2));
b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x.^2));
c=1./(2*cos(0.115*sqrt(5.63i*x+20.16)));
y=0;
f=499800*(abs(c)).^2*x*(exp(-2*y*a)+exp(2*y*a)+2*cos(2*y*b));
plot(x,f)
Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> dianjiao at 6
f=499800*(abs(c)).^2*x*(exp(-2*y*a)+exp(2*y*a)+2*cos(2*y*b));

Error using ==> mtimes Inner matrix dimensions must agree 用matlab求解时出现错误x=0:1:12;a=sqrt(10.08+0.5*sqrt(406.43+31.7*x.^2));b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x.^2));c=1./(2*cos(0.115*sqrt(5.63i*x+20.16))); y=0;f=499800*(abs(c)).^2*x*(e
注意,向量的话,这个根据你的需要应该改成点乘
clear;
clc;
x=0:1:12;
a=sqrt(10.08+0.5*sqrt(406.43+31.7*x.^2));
b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x.^2));
c=1./(2*cos(0.115*sqrt(5.63i*x+20.16)));
y=0;
f=499800*(abs(c)).^2.*x.*(exp(-2*y*a)+exp(2*y*a)+2*cos(2*y*b)); %%%注意这行的修改
plot(x,f)
或者干脆就用循环
clear;
clc;
x=0:1:12;
for ii = 1:length(x)
a=sqrt(10.08+0.5*sqrt(406.43+31.7*x(ii)^2));
b=sqrt(-10.08+0.5*sqrt(406.43+31.7*x(ii)^2));
c=1./(2*cos(0.115*sqrt(5.63i*x(ii)+20.16)));
y=0;
f(ii)=499800*(abs(c))^2*x(ii)*(exp(-2*y*a)+exp(2*y*a)+2*cos(2*y*b));
end
plot(x,f)