필터 지우기
필터 지우기

Drawing cross sectional views of a body using .mat file

조회 수: 1 (최근 30일)
Chris Dan
Chris Dan 2020년 2월 25일
답변: Hrishikesh Borate 2020년 12월 29일
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?

답변 (1개)

Hrishikesh Borate
Hrishikesh Borate 2020년 12월 29일
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.

카테고리

Help CenterFile Exchange에서 Inertias and Loads에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by