How do I plot cylinder bar in matlab?

4 ビュー (過去 30 日間)
laith Farhan
laith Farhan 2019 年 5 月 3 日
コメント済み: laith Farhan 2019 年 5 月 4 日
Dear all,
Is that possible to plot cylinder bar in matlab smilar to the picture below?
Let say my data is: x=[30,60,90]. I also would like to add x-axes and y-axes .
I appreciate it if you help me with example..
cy.jpg

回答 (1 件)

darova
darova 2019 年 5 月 3 日
You can manually create whatever you want
clc,clear
radius = 10;
[X, Y, Z] = cylinder(radius,30);
[X0, Y0] = sphere(20);
X0 = X0 * radius;
Y0 = Y0 * radius;
Z0 = zeros(size(X0));
cla, hold on
x = [30 60 90];
y = [15 12 20];
for i = 1:length(x)
X1 = X + x(i);
Z1 = Z.*y(i);
surf(X1,Y,Z1, 'FaceColor', 'm') % cylinder wall
surf(X0+x(i),Y0,Z0, 'FaceColor', 'm') % bottom
surf(X0+x(i),Y0,Z0+y(i), 'FaceColor', 'm') % top
end
hold off
xlabel('X axis')
ylabel('Y axis')
zlabel('Z axis')
axis equal
  1 件のコメント
laith Farhan
laith Farhan 2019 年 5 月 4 日
thanks Darova for your reply, but it didnt work for my case. I want the cylinder bar similar to the picture

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

カテゴリ

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