This is the error "Maximum variable size allowed by the program is exceeded". How can I fix it??

105 views (last 30 days)
Dear Sir,
I have this error"Maximum variable size allowed by the program is exceeded" and i do know how i fixed it....
I obtained on this error when I wrote this code:
x1= double(imread('image1.jpg'));
[C,S] = wavedec2(x1,1,'db5');
chd2 = wrcoef2('h',C,S,'db5',1);
D1=[];
D1 =[D1 chd2];
[h w] = size(D1)
s=2
t = 3;
b = 2*t+1;
N = h-b+1
M = w-b+1
L = N*M
r = [1:s:N]
r = [1:s:N]
r = [r r(end)+1:N]
c = [1:s:M]
c = [c c(end)+1:M]
X = zeros(b*b,L,'single')% here, I obtained on the error massage?????
where i can not make zero matrix...
I would like to help me in fixed this error...if this possible??
Thank you very much
  5 Comments
Randy Souza
Randy Souza on 29 Nov 2012
I have restored the original text of this question.
Mohamed Elwakdy, this question has a clear subject and multiple answers, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 7 Nov 2012
You need to either reduce L somehow, or switch to a 64 bit MATLAB with more than 9 Gb of memory.
Consider whether you algorithm really needs all of those locations.
Consider whether you will have a lot of zeros; if so then sparse matrices might help.
What is it that you are trying to accomplish?
  2 Comments
Walter Roberson
Walter Roberson on 7 Nov 2012
Why do you want to make a testing block, etc. ? What are you trying to compute? For example is this a radar application?
Walter Roberson
Walter Roberson on 7 Nov 2012
What will you be doing with X afterwards? Would it be possible to do some of the calculation in parts? Compute some of X and process that portion down to a smaller size, keep some overlap from X if needed but throw most of the already-processed part away, compute more of X, process that down, and so on?

Sign in to comment.


Jan
Jan on 6 Nov 2012
Edited: John Kelly on 13 Nov 2013
The maximum size of variables can be optained by the command computer. Because your b is small, L must be giantic, such that the internal addressing gets an overflow. Depending on the architecture, this can be at 2^40 (divided by b*b=49...).
  3 Comments
Jan
Jan on 7 Nov 2012
@Mohamed: As long as b=7, L = 23352784 should work. Are you sure that Matlab shows the error message for these values?
Exceeding the maximum size of arrays means, that you try to reserve more memory than Matlab and the operating system can access. But even below this limit you need very much RAM to process large arrays in a reasonable amount of time. So I assume, currently the problem you work on is too big for computers, and even if you split it in parts the calculations could take years.
But these assumptions are based on guessing only, because we still do not know the actual size of the problem, which produces the error message. Please type this in the command line:
dbstop if error
Then start your program. Matlab stops, when the error occurs and you can check the values of b and L.
Walter Roberson
Walter Roberson on 7 Nov 2012
(7 * 7) * 23352784 * 8 (bytes per double) = 9154291328 which is a little over 9 Gb, which is more than would be allowed on a 32 bit version of MATLAB.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!