%script template for ECE123 Assignment 1 %created 02/01/2008 by WAC % dtheta=1; theta=0:dtheta:180; %define angle vector in deg thetar=theta*pi/180; %convert to rad dthetar=dtheta*pi/180; esquare=sin(thetar).^2; %proportional to gain int=sum(esquare.*sin(thetar))*dthetar*2*pi; %integral of esquare over all angle % theta=0:dtheta:360; %define theta over 360 for plotting gain=4*pi*sind(theta).^2/int; %calc gain over 360 figure polar(theta*pi/180,gain) %note theta=0 is horizontal on the polar plot % [x,y,z]=sphere(128); gain=4*pi*(1-z.^2)/int; %calc gain in terms of z=cos(theta) xx=x.*gain; yy=y.*gain; zz=z.*gain; figure mesh(xx,yy,zz); %can use surf(xx,yy,zz) here too. axis equal %note theta=0 is vertical on the mesh plot