MATLAB: Video Processing: maximum variable size allowed by the program is exceeded

image processingvariablesvideo processing

Hi all,I'm now working on a project about Video processing, and I've having some problems. I'm processing some jpeg images which is 240*360 pixels, thus I have to create a matrix of 240*360 to store some processed data for each pixels, I tried to create such matrix using the command M=zeros(240:360) and it prompted me the error message 'maximum variable size allowed by the program is exceeded'. However, I tried to type the command M=zeros(360) and it works.
I don't really understand the situation, M=zeros(240:360) should return a matrix of 240*360 which contains 86400 elements, while the later command: M=zeros(360) should return a matrix of 360*360 which contains 129600 elements, obviously the later matrix occupies much more memory than the first one. But the program just allowed me to do the later operation, I'm now confused with the situation.
Indeed I can continue my project with a 360*30 matrix for each frames, however it doesn't seem to be efficient enough since there's more than thousands of frames for each video. Any answers will be appreciated:)

Best Answer

You must use
M=zeros(240,360) ; % this gives zeros matrix of size 240*360
When you type
M = zeros(240:360)
It tries to create a n dimensional matrix which goes out of memory. I tried to create a matrix like below, see what MATLAB says:
M=zeros(24:30) ;
Error using zeros Requested 24x25x26x27x28x29x30 (76.4GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become
unresponsive. See array size limit or preference panel for more information.