该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
同一个版本7.11.0.584 (R2010b),安装在一个32位台式机上,和一个64位笔记本上,操作系统都是win7。
同一个.m文件,在32位台式机上运行的好好的,但是在64位笔记本上就出错了!报错如下:
??? Error using==> mtimes
Inner matrixdimensions must agree.
Error in ==>evalincaller at 14
r =evalin('caller',a);
Error in ==>sym.eval at 33
r =evalin('caller',['evalincaller(''' sym2str(a) ''')']);
Error in ==>ColdHRBWO7 at 247
plot(rx,eval(SS(kn,1))/TP,'k','LineWidth',sqrt(abs(kn)));
经过检查,问题出在:
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*besselj(1,T(kn,1).*r).*besselj(1,T(kn,1).*r));
上。于是,我做了如下尝试:
(1) 我改成:
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*besselj(1,T(kn,1).*r));
在64位笔记本上就不出错了。但真正的公式里面,的确需要两个bessel公式相乘。
(2) 我又把两个bessel之间的.*改成*:
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*besselj(1,T(kn,1).*r)*besselj(1,T(kn,1).*r));
64位笔记本还出错!报的错误仍然是“Inner matrix dimensionsmust agree.”
(3) 我又改成如下两种形式:
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*(besselj(1,T(kn,1).*r))^2);
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*(besselj(1,T(kn,1).*r)).^2)
64位笔记本继续出错,报的错误又成了:“Inputs must be a scalarand a square matrix.”
出问题的程序段如下:
syms rz;
SS = zeros(2*n+1,1);
SS = sym(SS);
for kn=1:1:2*n+1
SS(kn,1) =real(omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*besselj(1,T(kn,1).*r).*besselj(1,T(kn,1).*r));
end
%#########################谐波功率#########################;
power=zeros(2*n+1,1);
TP = 0;
for kn=1:1:2*n+1
clear sp;
sp = @(z,r)real(besselj(1,T(kn,1).*r).*besselj(1,T(kn,1).*r).*r);
power(kn,1) =real(2*pi/p*omg*epsl*T(kn,1)*T(kn,1)*bt(kn,1)*A(kn,1)*A(kn,1)*quad2d(sp,0,0.5*p,0,Rw,'RelTol',1e-5,'MaxFunEvals',9000));
TP = TP + power(kn,1);
end
power = power/TP;
save power;
xlswrite('5-谐波功率.xls',power);
%#########################功率密度#########################;
rx = 0:0.01:(ro-d)*1e3;
r = rx*1e-3;
z = 0.5*p;
GLMD = rx';
figure(100);
for kn=1:1:2*n+1
clear GLMDn;
plot(rx,eval(SS(kn,1))/TP,'k','LineWidth',sqrt(abs(kn)));
hold on;
grid on;
box on;
xlabel('r-axis (mm)');
ylabel('Power flux density (W/m2)');
GLMDn = eval(SS(kn,1))/TP;
GLMDn = GLMDn';
GLMD = [GLMD,GLMDn];
end
save GLMD;
xlswrite('5-Poynting.xls',GLMD);