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 Center および File ExchangeBeamforming 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