How to solve "Error while using repmat : out of memory"
Show older comments
Hi all,
I was dealing with codes for image processing, where I need to use "repmat" function to create a big 5-d matrix, in a size of [116 116 72 64 64].
And it will give "out of memory" error.
The slice of code is shown below, it will give error when trying to assign new value to w (2nd row):
sq = repmat(sq, [1, 1, 1, 1, nd]);
w = repmat(reshape(w, [1, 1, 1, nd, nd]), [sx, sy, sz, 1, 1]);
raw = cat(4, s0, squeeze(sum(sq .* w, 4)));
Here , before these lines,
sq in [116 116 72 64]
w in [64, 64]
nd = 64, sx = sy = 116, sz = 72
What make things wield is, the size of matrix "sq" is in the same shape. And there will be no error when executing the first line of code, which means we could allocate enough space for a matrix in a size of [116 116 72 64 64].
As you can see, what I wanna do is creating w in the same shape as sp, and perform a element-wise multiplication. But the 2nd line will not work.
I tried to pre-allocate an empty matrix instead, by using zeros, but again get "out of memory" error.
Can anybody help me?
Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!