在
MATLAB
下極座標畫圖
採用polar或者polarplot函式
。在畫圖時,需要確定兩個變數,
一個是自變數,一個是因變數
。
一、自變數確定
確定自變數變化範圍以及變化精度。如,
deta=0。01;
theta = 0:deta:2*pi;
二、因變數確定
根據自變數變化情況計算因變數。如,
rho1 = sin(2*theta)。*cos(2*theta);
rho2 = sin(cos(theta))。*cos(2*theta);
【注意】在計算因變數時注意矩陣運算,要正確運用點乘、點除、點冪等操作運算子。
三、畫圖
1。polar(theta,rho,‘——r’)。%畫一個極座標圖,其中,曲線屬性,紅色虛線。更多polar函式的使用請參考
MATLAB polar函式
的使用說明。
圖1:rho1隨theta的變化極座標圖
2。
polarplot(angle,ee0,'b',angle,ee2,'r','LineWidth',1);
%畫兩張圖其中angle為自變數,ee0,ee2為因變數。線條顏色分別為藍色和紅色,線條寬度為1。更多使用情況可以參考MATLAB polarplot 函式的幫助文件。plarplot 的詳細例程如下,執行結果如圖2所示。
angle = -pi:0。005:pi;
N0=16;
for n=1:N0
E0=E0+exp(-1i*(n-1)*k*d0。*cos(angle));
E1=E1+exp(-1i*(n-1)*k*d1。*cos(angle));
end
ee0=abs(E0)/max(abs(E0));
ee2=abs(E1)/max(abs(E1));
fontsize=12;
p0=polarplot(angle,ee0,‘b’,angle,ee2,‘r’,‘LineWidth’,1);。。。
title(‘d=0。5mm,N=16/32線性陣元探頭指向性’,‘FontName’,‘TIMES NEW ROMAN|宋體’。。。 ,‘FontSize’,fontsize,‘FontUnits’,‘points’);
ax=gca;ax。FontName=‘TIMES NEW ROMAN |宋體’;
ax。FontSize=fontsize;ax。FontUnits=‘points’;
ax。ThetaGrid=‘on’;ax。GridLineStyle=‘——’;
ax。GridColor=[0 0 0];ax。LineWidth=1;
legend(‘16陣元’,‘32陣元’,‘Location’,‘northeast’);
圖2:畫圖結果