Thread Subject: Error :"In an assignment A(I) = B, the number of elements in B and I must be the same."
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a problem with calculating Ep(I). Any suggestion how to sole this problem?
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);
% Magnitude, Phase, X,Y,Z coordinate
for I = 1 : N
Current = I
An(I) = input ('Enter the Magnitude of the Current : ') ;
Jp(I) = input ('Enter the Phase 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 : ') ;
end
%azimut--> 0<Phi<360, elevation--> 0<Theta<180
Phhi = (0:1:360)*2*pi/180;
Thheta = (0:1:180)*2*pi/180;
[PHI,THETA] = meshgrid(Phhi,Thheta);
%R=[];
% calculate the array factor
for I = 1:N
Ep(I)= B.*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
R(I)= An(I).*exp(1i.*(Ep(I)+(Jp(I).*pi/180)));
end
h(THETA,PHI) = sum(R);
AF(THETA,PHI) = abs(h(THETA,PHI));
%plot the array factor
X = AF.*sin(THETA).*cos(PHI);
Y = AF.*sin(THETA).*sin(PHI);
Z = AF.*cos(THETA);
figure(2);
mesh(X,Y,Z); %display
%surf(X,Y,Z) %colored faces
Best regards, Tadej
댓글 수: 2
Walter Roberson
2011년 9월 12일
See also this earlier question on the same topic:
http://www.mathworks.com/matlabcentral/answers/14772-antenna-array-pattern-in-3d-space
채택된 답변
Walter Roberson
2011년 9월 12일
I already described to you before why you are getting this error: you are trying to fit a vector or higher dimensional data in to the scalar Ep. At the time I pointed out which variables were vectors. You should be able to calculate from that analysis what size and shape of value is being calculated in each iteration of the loop. When you ran in to problems last time, you should have used
dbstop if error
and then run your code, and when it stopped running, used size() to examine the size and shape of the inputs and used size() of the expression on the right hand side to figure out what size and shape the left hand side must be.
Hint: re-read the tags you gave to this question. How can you hope to achieve those goals by calculating scalar results?
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!