how can I make a colored 2D-surface in a polar plot? I want to give some labels to this polar... It is possible?

2 vues (au cours des 30 derniers jours)
clc
c=input('How many blades are there in the blower?:');
t = 0:.01:2*pi;
if mod(c,2)==1 polar(t,(cos((c*t))),'-r') else polar(t,(cos((c/2)*t).^2),'-r') end
% find all of the text objects in the polar plot
h = findall(gcf,'type','text');
% delete the text objects
delete(h);

Réponse acceptée

Joseph Cheng
Joseph Cheng le 7 Juil 2015
Modifié(e) : Adam Danz le 30 Sep 2025
the fill is a bit temperamental (does not work for odd blades). but it should be a starting point for you to look further.
clc
% c=input('How many blades are there in the blower?:');
c=randi(6,1,1);
t = 0:.01:2*pi;
if mod(c,2)==1
ph = polar(t,(cos((c*t))),'-r')
else
ph = polar(t,(cos((c/2)*t).^2),'-r')
end
ph =
Line with properties: Color: [1 0 0] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1 0.9991 0.9962 0.9915 0.9849 0.9764 0.9662 0.9542 0.9405 0.9251 0.9081 0.8896 0.8696 0.8482 0.8256 0.8017 0.7767 0.7507 0.7238 0.6960 … ] (1×629 double) YData: [0 0.0100 0.0199 0.0298 0.0394 0.0489 0.0580 0.0669 0.0754 0.0835 0.0911 0.0983 0.1049 0.1109 0.1163 0.1212 0.1253 0.1289 0.1317 0.1339 … ] (1×629 double) Use GET to show all properties
% find all of the text objects in the polar plot
h = findall(gcf,'type','text');
% delete the text objects
delete(h);
patch(get(ph,'XData'), get(ph,'YData'), 'g')
fins = linspace(0,360,c+1);
for ind = 1:c
txtx = 1.2*cosd(fins(ind));
txty = 1.2*sind(fins(ind));
text(txtx,txty,['fin ' num2str(ind)])
end

Plus de réponses (2)

bio lim
bio lim le 8 Juil 2015
clc
c=input('How many blades are there in the blower?:');
t = 0:.01:2*pi;
if mod(c,2)==1
radius = cos(c*t);
radius(radius <= 0) = 0;
ph = polar(t,(radius),'-r')
else
ph = polar(t,(cos((c/2)*t).^2),'-r')
end
% find all of the text objects in the polar plot
h = findall(gcf,'type','text');
% delete the text objects
delete(h);
patch(get(ph,'XData'), get(ph, 'YData'), 'b')
The rest is the code from Cheng, except the 'fins' was renamed to 'Blade' as the image suggested.
fins = linspace(0,360,c+1);
for ind = 1:c
txtx = 1.2 * cosd(fins(ind));
txty = 1.2 * sind(fins(ind));
text(txtx,txty,['Blade ' num2str(ind)])
end

Adam Danz
Adam Danz le 30 Sep 2025
Starting in R2025a, polar axes support patch and surface objects.
Here's @Joseph Cheng's example applied to polar axes.
There's more info about patch and surface support in polar axes in the Graphics and App Building blog.
c = 8;
t = linspace(0,2*pi,1000);
pax = polaraxes();
if mod(c,2)==1
patch(pax,t,(cos((c*t))),'-r')
else
patch(pax,t,(cos((c/2)*t).^2),'-r')
end

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by