Hi! I'm trying to play a movie from an array of frames that I recorded using surf. Here is the code that is generating an error:
zlim manual;frames(numel(T)) = struct('cdata',[],'colormap',[]);for frame_num = 1:numel(T) surf(reshape(KE(frame_num, 2:m-1, 2:n-1), m-2, n-2)); hold on surf(reshape(NE(frame_num, 2:m-1, 2:n-1), m-2, n-2)); hold off zlim([0 140]); frames(frame_num) = getframe();endfor frame_num = 1:numel(T) frames(frame_num).cdata = uint8(frames(frame_num).cdata);endmovie(frames, 5)
and here is the error:
Error using hgMovieMovie cdata must be of type uint8 arrayError in movie (line 41) builtin('hgMovie',varargin{:});Error in astro2d_main (line 110)movie(frames, 5)
I'm quite confused because a) I'm explicitly casting the cdata to uint8 and b) MATLAB reports that the data is in fact in the correct format anyway:
frames(1)ans = cdata: [343x435x3 uint8] colormap: []
Any help solving this would be wonderful! Thanks.
ps: let me add that the individual frames are rendering just fine and calling
image(frames(1).cdata)
does exactly what I expect it to.
Best Answer