フィルターのクリア

Creating multiple cylinders in different coordinates

4 ビュー (過去 30 日間)
sevgi
sevgi 2024 年 2 月 27 日
コメント済み: Star Strider 2024 年 3 月 2 日
I want to create cylinders with similar diameters and heights at various locations in x,y coordinates.
Could you help me
Thank you.

採用された回答

Star Strider
Star Strider 2024 年 2 月 27 日
編集済み: Star Strider 2024 年 3 月 1 日
Perhaps this —
[X,Y,Z] = cylinder(1,20);
cm = colormap(turbo(10));
figure
hold on
for k = 1:10
ofst = randi(9,2);
surf(X+2*ofst(1), Y+2*ofst(2), Z*5, 'FaceColor',cm(k,:))
end
hold off
grid on
axis('equal')
view(-27,30)
I set them to be different colours. If you wnat them all the same colour, just use:
surf(X+2*ofst(1), Y+2*ofst(2), Z*5)
instead.
EDIT — (1 Mar 2024 at 19:30)
In response to the rpoated request —
[X,Y,Z] = cylinder(9,20);
ofst = [0 0; 20 0; 10 20];
a = linspace(0,2*pi);
xc = 9*cos(a);
yc = 9*sin(a);
figure
hold on
for k = 1:size(ofst,1)
surf(X+ofst(k,1), Y+ofst(k,2), Z*65, 'FaceColor','g', 'EdgeColor','g', 'FaceAlpha',0.25)
plot3(xc+ofst(k,1), yc+ofst(k,2), 65*ones(size(a)), '-k', 'LineWidth',1)
plot3(xc+ofst(k,1), yc+ofst(k,2), 0*ones(size(a)), '-k', 'LineWidth',1)
end
hold off
grid on
axis('equal')
view(-27,30)
.
  2 件のコメント
sevgi
sevgi 2024 年 3 月 2 日
thank you for your interest.
Star Strider
Star Strider 2024 年 3 月 2 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (2 件)

Aquatris
Aquatris 2024 年 2 月 27 日
Not sure how you want them to look or what you need but here is one simple way
[X,Y,Z] = cylinder(2); % create X,Y,Z coordinates for a cyclinder with a radius 2
% define center positions
cycPos1 = [1 1 1];
cycPos2 = [4 4 4];
cycPos3 = [-3 -3 -3];
figure(1)
plotCyclinder(cycPos1,X,Y,Z)
plotCyclinder(cycPos2,X,Y,Z)
plotCyclinder(cycPos3,X,Y,Z)
% function that draws the cyclinders
function plotCyclinder(pos,X,Y,Z)
surf(pos(1)+X,pos(2)+Y,pos(3)+Z)
hold on
end
  1 件のコメント
sevgi
sevgi 2024 年 3 月 1 日
I want to create three solid cylinder volumes with a radius of 9 mm and a height of 65 mm at positions [0 0 0], [20 0 0], [10 20 0].
After that, I want to examine the thermal situation in the case of natural convection by defining temperature to the surface. I want to make an unsteady solution.
Could you help me.
Thank you for your interest.

サインインしてコメントする。


Matt J
Matt J 2024 年 3 月 1 日
編集済み: Matt J 2024 年 3 月 1 日
Using cylindricalFit() from this FEX download
centers={[0 0 0],[20 0 0],[10 20 0]};
for i=1:3
plot(cylindricalFit.groundtruth([],centers{i},9,65,[0,90]));hold on
end; hold off

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by