How to roll a 2d plot into a cylinder which then revolves?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
KSSV
am 14 Nov. 2018
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
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!