필터 지우기
필터 지우기

How to roll a 2d plot into a cylinder which then revolves?

조회 수: 4 (최근 30일)
Sree
Sree 2018년 11월 14일
댓글: Sree 2018년 11월 14일
Solution of an O.D.E. in a simple 1st order decay problem (that has periodic inputs) has yielded a 2d c vs t plot, with two curves: one for day 1, and the other, for day infinity; namely the cyclic steady state when day n+1 and day n yield the same c vs t curves. The second curve has the same c at te beginning and at the end of a 24 hr cycle, as it should. For engineering purposes, this plot is sufficient. But I want to make it jazzy and roll it up into a cylinder (which I can readily do with a print of the plot on paper), on the screen. The cylinder should revolve slowly about the z axis, thus illustrating the process cycle.

답변 (1개)

KSSV
KSSV 2018년 11월 14일
YOu may procedd something like below:
Radius = 1. ; % Radius of the cylindrical shell
theta = 360. ; % Angle of the Cylinder
Height = 2. ; % Height of the Cylinder
%
NH = 10 ; % Number of Elements on the Height
NT = 300 ; % Number of Angular Dicretisation
% Discretizing the Height and Angle of the cylinder
nH = linspace(0,Height,NH) ;
nT = linspace(0,theta,NT)*pi/180 ;
[H, T] = meshgrid(nH,nT) ;
% Convert grid to cylindrical coordintes
X = Radius*cos(T);
Y = Radius*sin(T);
Z = H ;
th = linspace(0,2*pi) ;
R = @(th) [1 0 0 ;0 cos(th) -sin(th) ; 0 sin(th) cos(th)] ; % rotation matrix alon x-axes
h = surf(X,Y,Z) ;
axis([-2 2 -2 2 -2 2])
coor = [X(:) Y(:) Z(:)] ;
for i = 1:length(th)
coor1 = coor*R(th(i)) ;
X1 = reshape(coor1(:,1),NT,NH) ;
Y1 = reshape(coor1(:,2),NT,NH) ;
Z1 = reshape(coor1(:,3),NT,NH) ;
set(h,'XData',X1,'YData',Y1,'ZData',Z1) ;
drawnow
pause(0.1)
end
  댓글 수: 1
Sree
Sree 2018년 11월 14일
Thanks. I am making progress with the function warp in the image processing toolbox:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by