Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Subscripted assignment dimension mismatch.
Replies: 1   Last Post: Oct 28, 2013 10:52 AM

 Messages: [ Previous | Next ]
 Siti Harwani Posts: 1 Registered: 10/28/13
Subscripted assignment dimension mismatch.
Posted: Oct 28, 2013 12:21 AM

Hi all,

I have the following program, but with this error [Subscripted assignment dimension mismatch.

Error in test_vlf_spherical (line 62)
ep(i,j)=ga(i,j)*ep(i,j)+gb(i,j)*((1./r(i)./dr)*(rph*hr(i,j)-rmh*hr(i-1,j))...]

i am trying to solve the problem by using (./) but i didnt work. can anyone help me to detect the problem? thank you

***********************
close all
clear all

k=200;
T=500;

c=3*10^8;
f=3*10^9;
lamda = c/f;
omega = 2*pi*f;

%ddx = lamda/20;
rr = 201;
dr = 0.05*lamda;
dt = dr/(2*c);
r = 0:dr:dr*(rr-1);

u0=4*pi*1e-7;
eps = 1/(4*pi*9*10^9);
sigma = 0;

t0 = 40;

%initialization
ep = zeros(k+1,k+1);
ht = zeros(k+1,k);
hr = zeros(k,k+1);

%ionospheric profile for earth-ionosphere waveguide as coefficients
omegap = 1;
epsr = 1;
sigmar = 1;

%property coefficient
for i=1:k
for j=1:k;
ga(i,j)=exp(-(sigmar*dt)/(eps*epsr));
gb(i,j)=(1./sigmar)*(1-exp(-(sigmar*dt)/(eps*epsr)));
end;
end;

%define theta
dth(2) = pi/180;

% update equations
for t=1:T
% source
pulse=sin(2*pi*f*t*dt);
ep(1,:)=pulse;

% update Ez field
for i=2:k
for j=2:k
rph = r(k)+dr/2;
rmh = r(k)-dr/2;
ep(i,j)=ga(i,j)*ep(i,j)+gb(i,j)*((1./r(i)./dr)*(rph*hr(i,j)-rmh*hr(i-1,j))...
-(1./r(i)./dth)*(ht(i,j)+ht(i,j-1)));
end
end
%
for j=1:k+1
ep(1,j)=0;
ep(i+1,j)=0;
end
for i=1:k+1
ep(i,1)=0;
ep(i,k+1)=0;
end
%

%update Ht (theta) field =Hx
for i=1:k+1
for j=1:k
rph = r(i)+dr/2;
rmh = r(i)-dr/2;
ht(i,j) = ht(i,j)+(dt/u0/r(i)/dr)*(rph*ep(i,j)-rmh*ep(i,j+1));
end
end

% update Hr field =Hy
for i=1:k
for j=1:k+1
hr(i,j) = hr(i,j)+(dt/u0/r(i)/dth/sin(dth))*(sin(dth(i+1))*ep(i+1,j)...
-sin(dth)*ep(i,j));
end
end

% plot
mesh(ep)
tm=['T=',num2str(t)]
text(10,100,0.5,tm)
axis([1 101 1 101 -1 1]);
drawnow;

end

**************************************

Date Subject Author
10/28/13 Siti Harwani
10/28/13 Curious