Subscripted assignment dimension mismatch.

2 ビュー (過去 30 日間)
Burak
Burak 2013 年 4 月 7 日
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

採用された回答

Ahmed A. Selman
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
  1 件のコメント
Burak
Burak 2013 年 4 月 7 日
really thanks , it worked but I am not sure the plot is correct.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by