Antenna array pattern in 3D space

7 次查看(过去 30 天)
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

采纳的回答

Wayne King
Wayne King 2011-8-30
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 个评论
Honglei Chen
Honglei Chen 2011-8-30
Phased Array System Toolbox is released in R2011a so you will need R2011a to use it. HTH.
Tadej
Tadej 2011-8-31
Downloading. Thank you Chen.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-8-30
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 个评论
Tadej
Tadej 2011-9-9
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 2011-9-9
Is there any different way to avoid error?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Antennas, Microphones, and Sonar Transducers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by