MATLAB Answers

0

time animation of a 3D matrix

Asked by Thomas Holmes on 21 Mar 2019
Latest activity Commented on by Thomas Holmes on 21 Mar 2019
I have a 14x14x221 matrix, A, where the Z component is time. I need to make a colored animation of how the X and Y components change with time. The code I have written now just creates a new figure for each iteration of the loop so it produces 221 figures that appear after closing out of the previous figure.
Q=length(A);
for i=1:Q
W=A(:,:,Q);
pcolor(W);
drawnow
pause(0.3)
end

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 21 Mar 2019
 Accepted Answer

Q = size(A,3);
W = A(:,:,1);
h = pcolor(W);
drawnow();
pause(0.3);
for K = 2 : Q
W = A(:,:,K);
set(h, 'CData', W);
drawnow();
pause(0.3);
end

  1 Comment

Sign in to comment.