From: Danna on 25 Jul 2010 14:40 want to make an animation where the figure rotates M=[-3,2,-1;4,-2,3;5,-4,-2;-3,2,-1]; rho = pi/8; figure, plot(M(1,:), M(2,:),'b.-', M(1,:), M(2,:),'*m'), axis( [-10,10,-10,10]); hold on RotMatrix=[cos(rho),-sin(rho),0;sin(rho),cos(rho),0;0,0,1]; for i = 1:64 M=M*RotMatrix; pause(.08) plot(M(1,:),M(2,:),'-.b',M(1,:),M(2,:),'*m'), end
From: us on 25 Jul 2010 15:10 "Danna " <silver_girl(a)hotmail.com> wrote in message <i2i0e4$l1m$1(a)fred.mathworks.com>... > want to make an animation where the figure rotates > > M=[-3,2,-1;4,-2,3;5,-4,-2;-3,2,-1]; > > rho = pi/8; > figure, plot(M(1,:), M(2,:),'b.-', M(1,:), M(2,:),'*m'), > axis( [-10,10,-10,10]); hold on > > RotMatrix=[cos(rho),-sin(rho),0;sin(rho),cos(rho),0;0,0,1]; > for i = 1:64 > M=M*RotMatrix; > pause(.08) > plot(M(1,:),M(2,:),'-.b',M(1,:),M(2,:),'*m'), > > end a hint: - peruse ML's stock function help comet; % to learn about animations us
From: Jan Simon on 25 Jul 2010 18:51 Dear Danna, > want to make an animation where the figure rotates It would be very helpful if you describe, why you think, your animation code is wrong. Errors? Unexpected results? Jan
From: Danna on 25 Jul 2010 19:12 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i2if4n$1g2$1(a)fred.mathworks.com>... > Dear Danna, > > > want to make an animation where the figure rotates > > It would be very helpful if you describe, why you think, your animation code is wrong. Errors? Unexpected results? > > Jan The figure its suposed to rotate, but it doesnt. I tried to adapt from this code: M = [1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; X = [1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; rho = pi/8; figure, plot(M(1,:), M(2,:),'b.-', M(1,:), M(2,:),'*m'), axis( [-10,10,-10,10]); hold on plot(X(1,:), X(2,:),'--g',X(1,:), X(2,:),'xr') TransOrigin=[1 0 1; 0 1 1; 0 0 1]; TransBack=[1 0 -1; 0 1 -1; 0 0 1]; RotMatrix=[cos(rho) -sin(rho) 0;sin(rho) cos(rho) 0; 0 0 1]; DilMatrix=[1.01 0 0;0 1.01 0; 0 0 1]; CompositionMatrix=TransBack*DilMatrix*RotMatrix*TransOrigin; for i = 1:64 M= CompositionMatrix*M; pause(.08) plot(M(1,:),M(2,:),'-.b',M(1,:),M(2,:),'*m'), X = CompositionMatrix*X; pause(.08) plot(X(1,:),X(2,:),'--g',X(1,:),X(2,:),'xr'), hold on end
From: us on 25 Jul 2010 19:39
"Danna " <silver_girl(a)hotmail.com> wrote in message <i2igc3$hru$1(a)fred.mathworks.com>... > "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i2if4n$1g2$1(a)fred.mathworks.com>... > > Dear Danna, > > > > > want to make an animation where the figure rotates > > > > It would be very helpful if you describe, why you think, your animation code is wrong. Errors? Unexpected results? > > > > Jan > > The figure its suposed to rotate, but it doesnt. I tried to adapt from this code: > > M = [1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; > X = [1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; > rho = pi/8; > figure, plot(M(1,:), M(2,:),'b.-', M(1,:), M(2,:),'*m'), > axis( [-10,10,-10,10]); hold on > plot(X(1,:), X(2,:),'--g',X(1,:), X(2,:),'xr') > TransOrigin=[1 0 1; 0 1 1; 0 0 1]; > TransBack=[1 0 -1; 0 1 -1; 0 0 1]; > RotMatrix=[cos(rho) -sin(rho) 0;sin(rho) cos(rho) 0; 0 0 1]; > DilMatrix=[1.01 0 0;0 1.01 0; 0 0 1]; > CompositionMatrix=TransBack*DilMatrix*RotMatrix*TransOrigin; > for i = 1:64 > M= CompositionMatrix*M; > pause(.08) > plot(M(1,:),M(2,:),'-.b',M(1,:),M(2,:),'*m'), > X = CompositionMatrix*X; > pause(.08) > plot(X(1,:),X(2,:),'--g',X(1,:),X(2,:),'xr'), hold on > end one of the solutions M=[1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; X=[1 2 2 1 1; 1 1 2 2 1; 1 1 1 1 1 ]; rho=pi/8; figure; axis([-10,10,-10,10]); hold on; ph1=plot(M(1,:),M(2,:),'b.-',M(1,:),M(2,:),'*m'); ph2=plot(X(1,:),X(2,:),'--g',X(1,:),X(2,:),'xr'); TransOrigin=[1 0 1; 0 1 1; 0 0 1]; TransBack=[1 0 -1; 0 1 -1; 0 0 1]; RotMatrix=[cos(rho),-sin(rho),0;sin(rho),cos(rho),0;0,0,1]; DilMatrix=[1.01,0,0;0,1.01,0;0,0,1]; CompositionMatrix=TransBack*DilMatrix*RotMatrix*TransOrigin; for i=1:64 M=CompositionMatrix*M; X=CompositionMatrix*X; pause(.08); set(ph1,... {'xdata'},num2cell(M(1,:),2),... {'ydata'},num2cell(M(2,:),2)); pause(.08); set(ph2,... {'xdata'},num2cell(X(1,:),2),... {'ydata'},num2cell(X(2,:),2)); end us |