新手求问,半波振子方向图怎么实现跟随theta和phi角而发生方向图偏转?

基础代码如下,怎么才能实现角度变化之后的方向图也跟着变化?需要增加哪些代码呀。。

clear all;clc;

theta=-pi/2:pi/100:pi/2;

phi=0:pi/100:2*pi;

for m=1:length(theta)

 E(m)=cos(pi*cos(theta(m))/2)/sin(theta(m));

 for n=1:length(phi)

  x(m,n)=E(m)*sin(theta(m))*cos(phi(n));

  y(m,n)=E(m)*sin(theta(m))*sin(phi(n));

  z(m,n)=E(m)*cos(theta(m));

end

end

surf(x,y,z);

希望能给个解答,谢谢大佬!