I'm running a for loop which currently animates surf
plots using columns 1:k (for k=1:301
) of 3 different matrices (representing x, y, and z) of dimension 21 x 602. However, simultaneously I want to surf plot columns for 302:k+301
, so that in essence, I get the animations of two flux tubes at the same time.
Currently, I have:
p = surf(nan(21,602), nan(21,602), nan(21,602));
for k = 1:301
% Update all of the plot objects at once
set(p, 'XData', x(:, 1:k), ...
'YData', y(:, 1:k), ...
'ZData', z(:, 1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
'facelighting','gouraud')
drawnow
end
But obviously, this is only plotting the first animation as it's currently written. How can this be adapted to also plot the other columns required (and therefore the other animation) at the same time?
Thanks
How about this:
p1 = surf([0 0 ;0 0]);
hold all
p2 = surf([0 0 ;0 0]);
for k = 1:301
% Update all of the plot objects at once
set(p1, 'XData', x(:,1:k), ...
'YData', y(:,1:k), ...
'ZData', z(:,1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
'facelighting','gouraud')
set(p2, 'XData', a(:,1:k), ...
'YData', b(:,1:k), ...
'ZData', c(:,1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
'facelighting','gouraud')
drawnow
end
hold off
x,y,z
is the data for one helix, and a,b,c
is the data for the other helix.
You need to create two different axes (p1
and p2
) so surf
wan't connect the data altogether
Hope it answers the question :)