MATLAB: How to specify the memory when run programs

insufficient memoryout of memory

I try to use the trainCascadeObjectDetector to train a detector for my own purpose.This function is provided in the MatLab R2013a and supports three feature type, that is HOG,LBP,HAAR. However, error occurs when HAAR is specified.The error are "Out of memory" or "Insufficient memory". I use the memory funtion and find Maximum possible array equals 500MB. Perhaps, this function needs more memory.
So, My question is whether the memory for an unique program can be specified,for example, 2GB for the function trainCascadeObjectDetector ? Or any similiar ways can solve the MEMory error.
Appreciated for every suggestion!

Best Answer

memory gives you the maximum amount of free memory at the time; how large an array can actually be created depends (as the note on the output says) on how much contiguous free memory is available--the total free may have been fragmented by earlier operations.
Look in the documentation under Resolving "Out of Memory" Errors under Advanced Software Development topic for suggestions to do what one can do.
The answer to the actual question asked is "no, you can't do that".