Respuesta aceptada

DGM
DGM el 6 de Abr. de 2021
Editada: DGM el 7 de Abr. de 2021
Try something like this
clf
r=[0.5 1]; % minor, major radii
h0=0; % base height
h=0.25; % height
th0=0; % start angle (degrees)
th=30; % included angle (degrees)
tt=linspace(th0,th0+th,10);
hh0=h0*ones(size(tt));
hh=h*ones(size(tt));
% plot the hollow segment
X = [r(1)*cosd([tt; tt]);
r(2)*cosd([tt; tt]);
r(1)*cosd(tt)];
Y = [r(1)*sind([tt; tt]);
r(2)*sind([tt; tt]);
r(1)*sind(tt)];
Z = [hh0; hh; hh; hh0; hh0];
surf(X,Y,Z,'facecolor','blue'); hold on
% one end face
X = [r(1)*cosd([th0 th0]);
r(2)*cosd([th0 th0])];
Y = [r(1)*sind([th0 th0]);
r(2)*sind([th0 th0])];
Z = [h0 h; h0 h];
surf(X,Y,Z,'facecolor','blue');
% the other end face
X = [r(1)*cosd([th th]+th0);
r(2)*cosd([th th]+th0)];
Y = [r(1)*sind([th th]+th0);
r(2)*sind([th th]+th0)];
Z = [h0 h; h0 h];
surf(X,Y,Z,'facecolor','blue');
axis equal
axis off
This is probably the long way to do it, but it works. I used to have a good demo for this, but idk what I did with it.

2 comentarios

Elsayed Khodry
Elsayed Khodry el 7 de Abr. de 2021
Editada: Elsayed Khodry el 7 de Abr. de 2021
How I can repeat it for n segments like the above picture?
DGM
DGM el 7 de Abr. de 2021
Editada: DGM el 7 de Abr. de 2021
Make a function out of it. The function should just take the parameters needed and plot one segment.
function bluepineapple(r,h,th)
h0=h(1);
h=h(2);
th0=th(1);
th=th(2);
tt=linspace(th0,th0+th,10);
hh0=h0*ones(size(tt));
hh=h*ones(size(tt));
% plot the hollow segment
X = [r(1)*cosd([tt; tt]);
r(2)*cosd([tt; tt]);
r(1)*cosd(tt)];
Y = [r(1)*sind([tt; tt]);
r(2)*sind([tt; tt]);
r(1)*sind(tt)];
Z = [hh0; hh; hh; hh0; hh0];
surf(X,Y,Z,'facecolor','blue'); hold on
% one end face
X = [r(1)*cosd([th0 th0]);
r(2)*cosd([th0 th0])];
Y = [r(1)*sind([th0 th0]);
r(2)*sind([th0 th0])];
Z = [h0 h; h0 h];
surf(X,Y,Z,'facecolor','blue');
% the other end face
X = [r(1)*cosd([th th]+th0);
r(2)*cosd([th th]+th0)];
Y = [r(1)*sind([th th]+th0);
r(2)*sind([th th]+th0)];
Z = [h0 h; h0 h];
surf(X,Y,Z,'facecolor','blue');
Then just call the function in a loop, adjusting the starting angle accordingly.
clf
r=[0.5 1]; % minor, major radii
h=[0 0.25]; % base, top height
th=[0 30]; % start, included angles (degrees)
n=6;
clf
for s=1:n
th(1)=360/n*(s-1);
bluepineapple(r,h,th);
end
axis equal
axis off

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Abr. de 2021

Editada:

DGM
el 7 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by