matlab - Animating a surf plot -


i've been tasked animating 3d helical flux tube in matlab , i'm unsure of how so.

the animation experience i've had plotting 2d trajectories of 9 solar system planetary orbits, used following code (where z 27 column matrix columns ordered in sequence x,y,z 9 times represent 9 planets)

% plot 9 empty plots p = plot3(nan(9), nan(9), nan(9));  k = 1:size(z, 1)     % update of plot objects @ 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, have tried adapt helical flux tube have follows (where x, y , z 21 x 301 matrices , assume @ each time step must surf rows of x,y , z accordingly required time step):

p = surf(nan(21,301), nan(21,301), nan(21,301));  k = 1:size(x,1)     % update of plot objects @ 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 keep getting error

error using matlab.graphics.chart.primitive.surface/set size mismatch in param cell / value cell pair. 

i know i've made silly mistake somewhere, can help? or if i'm going wrong way let me know?!

(nb if helps, in original script plot helical flux tube, code is:)

surf(x,y,z,'facecolor', colour, 'edgecolor',edgecolour,...     'facelighting','gouraud') 

thanks!!

i not 100% sure want try:

for k = 1:size(x,1)     surf(num2cell(x(1:k, :) ,num2cell(y(1:k, :), num2cell(z(1:k, :);     m(i)=getframe; end 

and display movie afterwards by:

numberofrepitions=3 % want have play in row movie(m,numberofrepetitions) 

maybe easier displayed on random data didnt provide any:

x=[1 2 3; 2 3 4; 3 4 5]; y=[19 17 15; 13 11 9; 7 5 3]; z=[1 1 2; 2 1 1; 3 3 3];  i=1:10     surf(x,y,z);      m(i)=getframe;     x=x+10;     y=y+20;     z=z+25; end  movie(m,3) 

the form of created plot doesnt change can see axis moving, guess work way varying form of surface triangulation.


Comments

Popular posts from this blog

Python Pandas join aggregated tables -

java - Static nested class instance -

java - How to access payload from REST 404 response in Camel cxfrs? -