tags:

views:

87

answers:

1

I'm doing CDMA spreading in MATLAB. And I'm having an Out of Memory error in MATLAB despite upgrading my RAM, preallocating arrays, etc.

Is there an alternate method to kron (Kronecker tensor product) in MATLAB? Here is my code:

tempData = kron( Data, walsh); 

Data is a M by 1 matrix and walsh (spread code) is a 8 by 1 matrix.

My Data is comprises of real and imaginary parts, e.g.: 0.000 + 1.000i or 1.000 + 0.000i in double format.

+3  A: 

This call to kron is not memory intensive. I know, your problem seems so trivial. However, you don't tell us what is M. For very large values of M, you are simply trying to create too large of an array to fit in memory. It is very easy to forget that your computer is not infinitely large or infinitely fast. We get spoiled when we see "giga" in front of everything.

If you absolutely must do this for that value of M, then you probably need the 64 bit version of MATLAB, AND more memory will always help once you do that.

Another option is to make Data single precision, if you can afford the loss in precision. This will at least give you an extra factor of 2. In order to provide the best help, we need to know the size of M.

woodchips
Ok, I'll go and try single format... M is in the millions
HH
Converting to single works! Thanks!
HH
Remember that if M is on the order of 5 million, then the result of this kron call has 4e7 elements. As complex numbers, this will take 6.4e8 bytes of memory. Matlab needs to find contiguous address space for this array. So if you have many other arrays in memory, one trick is to try pack, which can help to reduce the memory fragmentation. Single of course reduces that block to be 1/2 as large, so it solved your problem.
woodchips
Another thing to consider is if the data is sparse enough, then you should use sparse matrices. That can really save on memory.
Justin Peel

related questions