Subscripted assignment dimension mismatch.
2 次查看(过去 30 天)
显示 更早的评论
hi here is the function (1st one) that I have to calculate and plot http://i48.tinypic.com/axoarn.jpg , I changed my code like this and now I got this error Subscripted assignment dimension mismatch.
Error in ==> Untitled at 55 bes_kur_der(n,mg)=C;
How can I fix that? if true
clear all,
format long
tic
N_cut=20;
eps0=(10^-9)/(36*pi);
mu0=4*pi*10^-7;
epsr1=1.;
epsr2=2.;
mur1=1.;
mur2=1.;
eps1=epsr1*eps0;
eps2=epsr2*eps0;
mu1=mur1*mu0;
mu2=mur2*mu0;
freq=6*10^8;
omeg=2*pi*freq;
k=omeg*sqrt(eps1*mu1);
lambda=2*pi/k;
Mr=21;
Mtheta=21;
Mphi=21;
thetabegin=0.;
thetaend=2*pi;
deltatheta=(thetaend-thetabegin)/Mtheta;
phibegin=0.;
phiend=pi;
deltaphi=(phiend-phibegin)/Mphi;
Rbegin=0.;
Rend=0.4;
deltaR=(Rend-Rbegin)/Mr;
R=Rbegin:deltaR:Rend;
theta=thetabegin:deltatheta:thetaend;
phi=phibegin:deltaphi:phiend;
for mg=1:22
R(mg)=R(mg);
theta(mg)=theta(mg);
phi(mg)=phi(mg);
end
for mg=1:22
for n=1:N_cut
A=sqrt(pi.*k.*R(mg)./2).*besselh(n+0.5,2,k.*R(mg));
A(isnan(A))=0;
bes_kur(n,mg)=A;
B=sqrt(pi.*k.*R(mg)./2).*besselh(n+0.5,2,k.*R(mg));
B(isnan(B))=0;
han_kur(n,mg)=B;
C=-n.*sqrt(pi.*k./(2.*R(mg))).*besselj(n+0.5,k.*R)+k.*sqrt(pi.*k.*R(mg)./2).*besselj(n-0.5,k.*R(mg));
C(isnan(C))=0;
bes_kur_der(n,mg)=C;
D=-n.*sqrt(pi.*k./(2.*R(mg))).*besselh(n+0.5,2,k.*R(mg))+k.*sqrt(pi.*k.*R(mg)/2).*besselh(n-0.5,2,k.*R(mg));
D(isnan(D))=0;
han_kur_der(n,mg)=D;
a(n)=(1i.^n).*(2.*n+1);
b(n)=(-((1i.^n).*(2.*n+1).*bes_kur_der(n,mg)))./han_kur_der(n,mg);
c(n)=-((1i.^n).*(2.*n+1).*bes_kur(n,mg))./han_kur(n,mg);
end
end
for mg=1:22
for n=1:N_cut
L1=legendre(n,cos(theta(mg)));
L11=legendre(n-1,cos(theta(mg)));
L0(n,mg)=L1(1,:);
L2(n,mg)=L1(2,:);
if n==1
L3(n,mg)=0.;
else
L3(n,mg)=L11(2,:);
end
%L2_der(n,mg)=n*(cos(thetag(mg))*L2(n,mg)-L0(n,mg))/sin(thetag(mg));
% L2_der(n,mg)=-(n+1)*(cos(thetag(mg))*L2(n,mg)-L0(n,mg));
L2_der(n,mg)=(-(n+1)*L3(n,mg)+n*cos(theta(mg))*L2(n,mg))/sin(theta(mg));
E_theta(n,mg)=(1i/k*R(mg))*exp(-1i*k*R(mg)*cos(phi(mg))*(1i^n).*((b(n,R(mg)).*sin(theta(mg))).*L2_der(n,mg)).*(c(n,R(mg)).*L3(n,mg)./sin(theta(mg))));
end
end
F_Etheta=sum(E_theta,2);
figure
plot(R,abs(E_theta))
% code
end
0 个评论
采纳的回答
Ahmed A. Selman
2013-4-7
In the line
C=-n.*sqrt(pi.*k./(2.*R(mg))).*besselj(n+0.5,k.*R)+k.*sqrt(pi.*k.*R(mg)./2).*besselj(n-0.5,k.*R(mg));
use R(mg) as in:
C=-n.*sqrt(pi.*k./(2.*R(mg))).*besselj(n+0.5,k.*R(mg))+k.*sqrt(pi.*k.*R(mg)./2).*besselj(n-0.5,k.*R(mg));
Also, there is a line where you defined b(n,R(mg))at E_theta(n,mg) (the end of the code). This needs rechecking because b has one dimension.
At the beginning of the lops, you have the following unnecessary lines, delete them to fasten the run.
for mg=1:22
R(mg)=R(mg);
theta(mg)=theta(mg);
phi(mg)=phi(mg);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!