Question

I just have a brief question regarding MatLab.

Say that we have the equation:

r^2 = 2 sin(5t)

I know that I can fill a polar plot by writing, say:

t = linspace(0,2*pi,200);
r = sqrt(abs(2*sin(5*t)));
x = r.*cos(t);
y = r.*sin(t);
fill(x,y,'k')

But say I use the ezpolar instead by giving the equation above a function handle and then typing:

ezpolar(function handle)

Is there any way I can then fill this polar plot? Or do I have to use the procedure outlined above?

Any tips/help will be greatly appreciated!

Was it helpful?

Solution

You can use ezpolar, then modify the resulting figure. If you look at the returned handle from ezpolar, you'll see it is the line itself drawn in the axis. The points from that line object can be extracted, then used to lay a new polygon on top of the same axis. The benefit is, you get to keep all the nice polar lables.

h=ezpolar('sqrt(abs(2*sin(5*t)))')
hold on;
fill(get(h, 'XData'), get(h, 'YData'), 'k');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top