incorrect input to ezplot function
3 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
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))
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!