Reputation: 25
the question Given N=1, an antenna has a radiation pattern given as y(theta)=sin(N4pitheta)/(N4pitheta) Assume that the formula is valid over the range of . Generate a polar plot of the radiation pattern. Use 400 points for your graph.
here is my code, I keep getting "THETA and RHO must be the same size." what does this mean and how can I fix my cod? thanks
function [graph,x,y]=question3(N)
x=linspace(-pi,pi,400);
y=(sin(N*4*pi*x)/(N*4*pi*x));
graph='polar(x,y)';
end
Upvotes: 0
Views: 353
Reputation: 35525
Your problem is that you are performing matrix division, not elementwise division.
change y=(sin(N*4*pi*x)/(N*4*pi*x))
to y=(sin(N*4*pi*x)./(N*4*pi*x))
Note that in Matlab, *
and /
will perform matrix operations while .*
and ./
will perform array operations.
Side note: It looks like you are using eval
to evaluate the output of that function. If it is your profesor who did this, leave it, but remember that even Matlab staff themselves suggest never to use eval.
Upvotes: 3