incorrect input to ezplot function

조회 수: 2 (최근 30일)
Venkat Raman
Venkat Raman 2020년 1월 19일
댓글: Venkat Raman 2020년 1월 19일
I'm getting the message 'Input must be a string expression, function name, function handle, or INL'. 'E' is indeed a function of Theta. The code is attached below. The E field values for different values of Theta are displayed on the command window but it is not getting plotted. How do I go about this?
%The script aims to plot the 2D radiation pattern of an antenna array
%The constants used are f,c,k,dx,dy,q,M,N,focal and phi
%Electric field varies only with Theta
f = input('Enter the input frequency in GHz ');
c = 3*(10^8); %speed of light, constant
k = (2*180*(f*1e9))/c; %computes wavenumber
dx = input('Enter the row-wise inter-element spacing ');
dy = input('Enter the column-wise inter-element spacing ');
q = input('Enter q for cosine power radiation pattern of horn ');
focal = input('Enter the focal length ');
M = input('Enter the number of rows: M ');
N = input('Enter the number of columns: N ');
Phi = 0; % We take phi as zero
Theta = -90:1:90; %angle varies from -pi/2 to +pi/2
%syms Theta Phi
% Array factor is dependent only on Theta and not on phi
AFtot= 0; % Initializing the total array factor to zero
for m = (-M+1) : M
for n = (-N+1): N
Rmn = sqrt((((m-0.5)*dx)^2) + (((n-0.5)*dy)^2) + (focal^2));
Rr = sin(Theta)*dx*(m-0.5); %Rr is the dot product of rmn vector and rcap vector
Phimn = (k*(Rmn-Rr))- 2*180; %Computes phimn
E = exp(1i*(Phimn+Rr-(k*Rmn)));
AF = E.*((cos(Theta)).^q)/Rmn;
AFtot = AFtot + AF;
end
end
E = AFtot.*cos(Theta); %Computes the Electric field pattern
disp(E);
ezplot(E);

답변 (1개)

Turlough Hughes
Turlough Hughes 2020년 1월 19일
편집: Turlough Hughes 2020년 1월 19일
ezplot requires a function handle as an input whereas you are inputting a vector. Seeing as you have the results as a vector I think it would be most straightforward to use plot instead of ezplot
plot(E)
Or perhaps
plot(Theta,real(E))
  댓글 수: 1
Venkat Raman
Venkat Raman 2020년 1월 19일
I've noted your point. Glad to receive the suggestion.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Beamforming and Direction of Arrival Estimation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by