作业帮 > 综合 > 作业

Matlab积分问题?Function 'eval' is not defined for values of clas

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/08/08 07:47:02
Matlab积分问题?Function 'eval' is not defined for values of class 'double'.
Lamda=1550e-9;
R=3e-3;
F=1;
C=1/(i*Lamda);
k=2*pi/Lamda;
syms m n r1 a1;
r2=linspace(0,27e-3,1000); %屏上半径
a2=linspace(0,360,3600); %角度微分
E=zeros(1000,3600);
E1=E;E2=E;
for m=1:1000;
for n=1:3600;
E1(m,n)=double(int((int(cos(r1*cos(a1)/F*r2(m)*cos(a2(n))+r1*sin(a1)/F*r2(m)*sin(a2(n)))*exp(r1^2/(2/R^2))*r1,r1,0,3e-3)),a1,0,360));
E2(m,n)=double(int((int(-i*sin(r1*cos(a1)/F*r2(m)*cos(a2(n))+r1*sin(a1)/F*r2(m)*sin(a2(n)))*exp(r1^2/(2/R^2))*r1,r1,0,3e-3)),a1,0,360));
E(m,n)=(E1(m,n)+E2(m,n))*C/F*exp(i*k*F)*exp(i*k*r2(m)/(2*F));
end
end
imshow(E^2*255);
提示的错误信息是:
Function 'eval' is not defined for values of class 'double'.
Error in ==> eval at 44
[varargout{1:nargout}] = builtin('eval',varargin{:});
Error in ==> sym.double at 45
D = reshape(eval(X),siz);
Matlab积分问题?Function 'eval' is not defined for values of clas
出错在E1赋值时用了double转换,但你定义的a1就一符号,你让matlab怎么帮你把它转成数值?
再问: a1定义的不是一维矩阵么?我把double去掉了没有报错但是没有计算结果。
我现在改成了不用int来做积分,直接用循环累加来计算积分了,已经解决问题了。
还是谢谢你!