Ria George
Ria George

Reputation: 393

Matlab: out of memory for 3 D matrices

I am N = 10^6 data points and want to create (a) a N by N 2D matrix,A (b) and assign the values of P into the third dimension of a 3D matrix B. For N = 256 to N =1000, the following works

A = 0.1*eye(N,N);
 B(:,:,1) =A;     

But for higher values of N, I am getting out of memory error. So, I found that I can create a sparse matrix instead of using eye as A = 0.1*eye(N,N); But then B cannot be created as that operation does not work for sparse. How can I find a way out? Thank you

Upvotes: 1

Views: 54

Answers (1)

Mehrdad Nazmdar
Mehrdad Nazmdar

Reputation: 192

You can use cell arrays.

B=cell(1000000);
B{1}=A;

This is for memory storage only.I don't know what you are going to do finally. Hope this will help.

Upvotes: 1

Related Questions