2013-01-05 177 views
3

天線輻射的特點,我需要繪製該功能enter image description here繪製在MATLAB

theta = (-pi:0.01:pi); 
f = 3*10^9; 
c = 299792458; 
da = 2; 

這裏是我的代碼,但我不知道它是正確的。我不知道應該在哪裏。如何設置X軸爲遞減?

beta = (2*pi*f)/c; 
const= (da*beta)/2; 
j= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta))); 

我的另一個問題是如何在極座標中繪製該函數。

我做了這樣的事情。

polar(theta,j); 

是否可以旋轉該函數(通過y軸)來獲得3D圖?

回答

1

事情對我來說很合適,但我不會使用符號j作爲變量,因爲(如i那樣)它是虛構單元的符號(sqrt(-1))。這樣做是爲了覆蓋它,因此事情將起作用,直到你不需要複雜的數字爲止。

如果您的目標是按照元素組合數組條目,則應該使用基於元素的操作,例如(.*),正如您正確獲取F(\theta)一樣。實際上,cos(theta)是包含在theta等中的角度的餘弦陣列。

最後,您可以使用命令Rotate 3D在繪圖窗口中旋轉繪圖。儘管如此,你有一條二維曲線(F(\theta)),因此,你將繼續旋轉一個二維圖形獲得某種的透視圖它,只不過是。要獲得真正的信息,你需要一個額外的因變量(或者我誤解了你的問題?)。 enter image description here

編輯:現在我明白你的意思,你希望周圍的一些線,我想憑藉對稱Surface of revolution其中是theta=0。那麼,旋轉表面可以通過一些解析幾何圖形來獲得,並繪製成例如通過使用mesh。檢查了這一點:

% // 2D polar coordinate radius (your j) 
    Rad= (cos(theta)+1).*(besselj(1,const*sin(theta))./(const*sin(theta))); 
    Rad = abs(Rad); % // We need its absolute value for sake of clarity 


    xv = Rad .* cos(theta); % // 2D Cartesian coordinates 
    yv = Rad .* sin(theta); % // 2D Cartesian coordinates 

    phi = -pi:.01:pi;  % // 3D revolution angle around theta = 0 

    % // 3D points of the surface 
    xf = repmat(xv',size(phi)); 
    yf = yv' * cos(phi); 
    zf = yv' * sin(phi); 

    mesh(xf,yf,zf) 

enter image description here

您還可以通過

mesh(xf,yf,zf,'FaceColor','interp','FaceLighting','phong') 
camlight right 

和更細的角度離散(1e-3)添加圖形效果

enter image description here

做到這一點。

+0

我想得到像這樣的東西http://imageshack.us/photo/my-images/818/3dplot.png/ – daredesm

+1

@daredesm,我明白了你的觀點,圍繞哪一軸想要革命完成? 'theta = 0'? – Acorbe

+1

@daredesm,請檢查更新的答案。 – Acorbe