I've been tasked with animating a 3d helical flux tube in Matlab and I'm unsure of how to do so.
The only animation experience I've had was for plotting the 2d trajectories of 9 solar system planetary orbits, for which I used the following code (where z was a 27 column matrix whose columns were ordered in the sequence x,y,z 9 times as to represent 9 planets)
% Plot 9 empty plots
p = plot3(nan(9), nan(9), nan(9));
for k = 1:size(z, 1)
% Update all of the plot objects at once
set(p, {'XData'}, num2cell(z(1:k, 1:3:25), 1).', ...
{'YData'}, num2cell(z(1:k, 2:3:26), 1).', ...
{'ZData'}, num2cell(z(1:k, 3:3:27), 1).')
drawnow
end
So, intuitively, I have tried to adapt this for the helical flux tube that I have as follows (where x, y and z are 21 x 301 matrices and so I assume that at each time step I must surf the rows of x,y and z accordingly up to the required time step):
p = surf(nan(21,301), nan(21,301), nan(21,301));
for k = 1:size(x,1)
% Update all of the plot objects at once
set(p, {'XData'}, num2cell(x(1:k, :), [1 301]), ...
{'YData'}, num2cell(y(1:k, :), [1 301]), ...
{'ZData'}, num2cell(z(1:k, :), [1 301]))
drawnow
end
However, doing this i keep getting the error
Error using matlab.graphics.chart.primitive.Surface/set
Size mismatch in Param Cell / Value Cell pair.
I know I've probably made a silly mistake somewhere, but can anyone help? Or if I'm completely going about this the wrong way could anybody let me know?!
(NB If it helps, in the original script to plot the helical flux tube, the code is:)
surf(x,y,z,'facecolor', Colour, 'edgecolor',EdgeColour,...
'facelighting','gouraud')
Thanks!!