1. 程式人生 > >Matlab在極坐標中繪圖

Matlab在極坐標中繪圖

red 格式 ise 方式 通過 med coord radi esc

在極坐標中繪圖

以下示例演示如何在極坐標中創建線圖、散點圖和直方圖。此外,還演示了如何對極坐標圖添加註釋和更改軸範圍。

創建極坐標線圖

通過極坐標中的天線以可視方式呈現輻射圖。加載文件 antennaData.mat,該文件包含變量 thetarho。變量 rho 用於測量天線對 theta 的每個值的輻射強度。通過使用 polarplot 函數在極坐標中繪制數據圖來對該輻射圖進行可視化。

load(fullfile(matlabroot,‘examples‘,‘matlab_featured‘,‘antennaData.mat‘))

figure
polarplot(theta,rho)

技術分享圖片

多個極坐標線圖

使用 hold on 保留當前極坐標區,然後通過 polarplot 繪制其他數據圖。

rng(‘default‘)
noisy = rho + rand(size(rho)); 
hold on
polarplot(theta,noisy)
hold off

技術分享圖片

為極坐標圖添加註釋

使用 legendtitle 之類的註釋函數標記與其他可視化類型類似的極坐標圖。

legend(‘Original‘,‘With Noise‘)
title(‘Antenna Radiation Pattern‘)

技術分享圖片

更改極坐標區範圍

默認情況下,在極坐標圖中,半徑的負值將被繪制為正值。使用 rlimr 坐標軸範圍調整為包含負值。

rmin = min(rho);
rmax = max(rho);
rlim([rmin rmax])

技術分享圖片

使用 thetalimtheta 坐標軸範圍更改為 0 和 180。

thetalim([0 180])

技術分享圖片

創建極坐標散點圖

在極坐標中繪制風速數據圖。加載文件 windData.dat,該文件包含變量 directionspeedhumidity

C。通過使用 polarscatter 函數在極坐標中繪制數據圖來以可視方式呈現風速圖。

load(fullfile(matlabroot,‘examples‘,‘matlab_featured‘,‘windData.mat‘))
polarscatter(direction,speed)

技術分享圖片

包括第三個數據輸入以改變標記大小並表示第三個維度。

polarscatter(direction,speed,humidity)

技術分享圖片

使用格式化輸入調整標記顯示屬性。

polarscatter(direction,speed,humidity,C,‘filled‘)

技術分享圖片

創建極坐標直方圖

使用 polarhistogram 函數以可視方式呈現數據,這將會生成稱為風向圖的可視表示形式。

polarhistogram(direction)

技術分享圖片

指定 bin 確定算法。polarhistogram 函數具有各種確定 bin 數量和 bin 寬度的算法,可從 BinMethod 字段中選擇。

polarhistogram(direction,‘BinMethod‘,‘sqrt‘)

技術分享圖片

指定 bin 數量和 bin 寬度。

polarhistogram(direction,24,‘BinWidth‘,.5)

技術分享圖片

指定歸一化方法並調整顯示樣式以排除任何填充。

polarhistogram(direction,‘Normalization‘,‘pdf‘,‘DisplayStyle‘,‘stairs‘)

技術分享圖片

Matlab在極坐標中繪圖