Clear Filters
Clear Filters

Antenna array pattern in 3D space

7 views (last 30 days)
Tadej
Tadej on 30 Aug 2011
Hy guys. Can please someone help me. When I start the program I have an error: Error: Unexpected MATLAB operator.
%Tadej Trinko; three-dimensional antenna array pattern
%email:tadej.trinko@gmail.com
%Jožef Štefan International Postgraduate School (MPS IJS), Ljubljana,
%Slovenia
clear all;
% element numbers N, wavenumber B
N = input ('Enter the Number of Array Elements : ') ;
lambda = input ('Enter the Value of Lambda (c/f) : ') ;
B =(2*pi/lambda);
j = sqrt(-1);
% Magnitude, Phase, X,Y,Z coordinate
for I = 1 : N
Current = I
An(I) = input ('Enter the Magnitude of the Current : ') ;
Xn(I) = input ('Enter the Position of Element on X-axis : ') ;
Yn(I) = input ('Enter the Position of Element on Y-axis : ') ;
Zn(I) = input ('Enter the Position of Element on Z-axis : ') ;
Jp(I) = input ('Enter the Phase of the Current : ') ;
end
Phi=(0:1:360)*pi/180;
Theta=(0:1:180)*pi/180;
[THETA,PHI]=meshgrid(Theta,Phi);
% calculate the array factor
for I=1:N
R=An(I)*exp(1j.*(Ep+Jp(I)));
Ep=B*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
end
%plot the array factor
X=R.*sin(THETA).*cos(PHI);
Y=R.*sin(THETA).*sin(PHI);
Z=R.*cos(THETA);
figure();
mesh(X,Y,Z); %display
surf(X,Y,Z) %colored faces
Thank you for any advice or comment.
Regards, Tadej

Accepted Answer

Wayne King
Wayne King on 30 Aug 2011
Hi Tadej, In this for loop
for I=1:N
R=An(I)*exp(1j.*(Ep+Jp(I)));
Ep=B*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
end
You attempt to access the value of Ep the first time through the loop before it has been assigned a value. Perhaps you just need to swap the two lines and place the Ep= assignment before the R=
Also, do you know about the new Phased Array System Toolbox? That toolbox will greatly enhance your ability to design antennas and model phased array systems.
Wayne
  4 Comments
Honglei Chen
Honglei Chen on 30 Aug 2011
Phased Array System Toolbox is released in R2011a so you will need R2011a to use it. HTH.
Tadej
Tadej on 31 Aug 2011
Downloading. Thank you Chen.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 30 Aug 2011
Which line does it complain about, and which column?:
I am not sure that 1j can be used to mean 1 times the imaginary unit. I know 1i can be used. As you defined j as sqrt(-1) it would seem to be more consistent for you to use 1*j in that location.
Your second "for" loop, the one with the comment "calculate the array factor", does not store its results, and does not use the results in further computation. That is going to cause R and Ep to be overwritten during each iteration of the loop, and so will contain only a single value at the end of the loop.
I would suggest that you want R(I)= ... and Ep(I) = ... but the Ep expression appears to have a vector result, so at the very least it would have to be Ep(I,:) or Ep(:,I). I also see that If you were to use R(I) then R would end up of length N, but R is then .* by trig array values that are 361 x 181 so multiplying by a vector R of length N is problematic.
Your code appears to be incomplete and incorrect.
  9 Comments
Tadej
Tadej on 9 Sep 2011
You are correct Walter. Everytime I get error:
??? Subscripted assignment dimension mismatch.
Error in ==> Array3Dex6 at 31
Ep(:,I)= B.*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
Tadej
Tadej on 9 Sep 2011
Is there any different way to avoid error?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!