% pattern of a thin wire of lengh L clear rad=pi/180; k=2*pi; L=input('Enter wire length in wavelengths: '); kl=k*L; it=0; for th=0:1:360 thr=th*rad; it=it+1; E=0; if abs(sin(thr))>0.0001 E=(cos(kl*cos(thr)/2)-cos(kl/2))/sin(thr); end F(it)=abs(E); TR(it)=th*rad; T(it)=th; Fdb(it)=20*log10(abs(E)+1e-2); end figure(1),clf subplot(121),polar(TR,F/max(F),'k-') title('Polar Voltage Plot') subplot(122),polardb(T,Fdb-max(Fdb),'k-') % note: title location based on 40 dB dynamic range text(-15,40*1.3,'Polar dB Plot') it=0; for th=0:3:180 jt=0; it=it+1; for ph=0:3:360 jt=jt+1; thr=th*rad; phr=ph*rad; phd(it,jt)=ph; thd(it,jt)=th; ct=cos(thr); E=0; if abs(sin(thr))>0.0001 E=(cos(kl*cos(thr)/2)-cos(kl/2))/sin(thr); end u=sin(thr)*cos(phr); v=sin(thr)*sin(phr); w=cos(thr); ff=abs(E); f(it,jt)=ff; X(it,jt)=f(it,jt)*u; Y(it,jt)=f(it,jt)*v; Z(it,jt)=f(it,jt)*w; end end MAX=max([max(max(X)),max(max(Y)),max(max(Z))]) figure(2),clf mesh(X/MAX,Y/MAX,Z/MAX) axis([-1,1,-1,1,-1,1]) axis square hold on plot3([0 0],[0 0],[-1 1],'k-') xlabel('X=|E|sin(t)cos(p)') ylabel('Y=|E|sin(t)sin(p)') zlabel('Z=|E|cos(t)');