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

 Accepted Answer

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 Comments

Thanks a lot. This is a great solution :)
Bahar
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)

Sign in to comment.

More Answers (0)

Categories

Asked:

on 19 Aug 2015

Commented:

on 20 Aug 2015

Community Treasure Hunt

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

Start Hunting!