Drawing cross sectional views of a body using .mat file

3 visualizzazioni (ultimi 30 giorni)
hello,
I have this data of a cylinder
The first column is the length of each section in meters starting from 0 till the end of cylinder at 0.4960.
The second column is the outer diameter and the third column is the inner diameter.
I want to draw its cross sectional view on matlab.
I have this code
for i =1:1:1
MD(:,1) = MD(:,1)
a = size(MD,1);
for j =1:1:(a-1)
coord = MD(j:j+1,:);
rectangle('Position',[coord(1,1) 0 coord(2,1)-coord(1,1) coord(1,2)])
axis([0 0.2 0 0.02])
hold on
end
end
This code draws the rectangles but they are not correct I want to draw some thing like this
it should draw rectangles, but two rectangles for hollow cylinder and 1 for non hollow cylinder.
Does anyone knows?

Risposte (1)

Hrishikesh Borate
Hrishikesh Borate il 29 Dic 2020
Hi,
I understand that you want to draw the cross-sectional view of a cylinder from the data in MD variable.
Following is an example code, upon which you can build up as per your requirements.
MD = [0, 0.0480, 0.0380;...
0.0255, 0.0480, 0.0210;...
0.0770, 0.0660, 0.0210;...
0.1120, 0.0600, 0.0210;...
0.1880, 0.0600, 0.0210;...
0.2030, 0.0600, 0.0350;...
0.3040, 0.0480, 0.0350;...
0.4130, 0.0480, 0.0380;...
0.4960, 0.0480, 0.0380];
[x1, y1, z1] = cylinder(MD(:,2));
[x2, y2, z2] = cylinder(MD(:,3));
z = MD(:,1).*ones(1,21);
halfPts = floor(length(x1)/2);
surf(x1(:,1:halfPts), y1(:,1:halfPts), z(:,1:halfPts));
hold on;
surf(x2(:,1:halfPts), y2(:,1:halfPts), z(:,1:halfPts));
hold off;
For more information, refer to cylinder.

Categorie

Scopri di più su Inertias and Loads in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by