Plotting polar graphs with Matlab

Hi, I am using Matlab to generate symmetric polar plots on the lower half of the circle (i.e. 0-83 degrees and 277-360 degrees).
h = polar(phi,rho)
where phi and rho are input text files.
In this case, Matlab connect the point of (phi_83,rho_83) to (phi_277,rho_277) with one straight line. How can I modify it so that they don't get connected?
Thanks a lot, Bahar

 採用された回答

Star Strider
Star Strider 2015 年 8 月 20 日

1 投票

You have to break them up into two separate plot calls, and use the hold function:
phi = [linspace(0, 83) linspace(277, 360)]*pi/180; % Create Data
rho = abs(sin(6.5*phi)); % Create Data
figure(1)
polar(phi(1:100), rho(1:100))
hold on
polar(phi(101:200), rho(101:200))
hold off
The linspace function creates a 100-element vector by default. You can change that with a third argument, but you would have to change the subscripts in the polar calls to match the new vector lengths.

2 件のコメント

Bahar
Bahar 2015 年 8 月 20 日
Thanks a lot. This is a great solution :)
Bahar
Star Strider
Star Strider 2015 年 8 月 20 日
My pleasure! Thank you for the compliment!
Another possibility (but probably not always applicable) is to insert NaN values in both vectors. (Here, ‘rho’ will include them automatically, because it’s calculated from ‘phi’.)
For example:
phi = [linspace(0, 83) NaN linspace(277, 360) NaN]*pi/180; % Create Data
rho = abs(sin(6.5*phi)); % Create Data
figure(1)
polar(phi, rho)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

質問済み:

2015 年 8 月 19 日

コメント済み:

2015 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by