Plotting polar graphs with Matlab
11 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Star Strider
on 20 Aug 2015
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
Star Strider
on 20 Aug 2015
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)
More Answers (0)
See Also
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!