Using cell array to create 3D sparse matrix.

7 views (last 30 days)
Hello, I would like to create a 3d-sparse matrix. Ofc, I know that matlab's toolbox doesn't have it so far.
Here is my code :
C=zeros(m^nun,m,nu);
I would like to use a cell array filled with 2d sparse matrix. Something like :
A = zeros(m^nun, 1);
B = cell(size(A));
SP = sparse(m, nu);
for j=1:m^nun
B{j} = SP;
end
Is it the right way to do it ?
Furthemore, can I use my matrix B in the same way as my matrix C ? For example, here is my code (and it works) :
C(1:x,A,1)=N;
But is it going to work with my matrix B as well ? (by doing : B(1:x,A,1)=N;)
Thank you, and sorry for the long post.

Answers (1)

Matt J
Matt J on 2 Oct 2012
Edited: Matt J on 2 Oct 2012
Consider using this FEX contribution instead
It will let you do many/most things that you can do with 3D full arrays.
  17 Comments
Collet Bastien
Collet Bastien on 10 Oct 2012
Edited: Collet Bastien on 10 Oct 2012
Ok,I'm looking for a new matlab version, I'm also going to send you the variables too.
Matt J
Matt J on 10 Oct 2012
I received your file, but
PV(:,:,1)=AAA;
works fine for me. I'm betting that upgrading will fix it.

Sign in to comment.

Categories

Find more on Sparse 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!