Reputation:
I am trying to create variable number of sparse matrices. At first the best solution seemed to be creating a cell array and iteratively adding matrices to it however, e.g. the following code;
arr = {};
for i = 1:10
arr = [arr sparse([],[],[],1000,1000)];
end
gives:
Error using ==> horzcat Attempt to convert to unimplemented sparse type
error. Do you have any suggestions?
Upvotes: 0
Views: 282
Reputation: 5014
Minor modification to your loop. Since you create the cell, assign a matrix in a cell element in each iteration:
arr = cell(1,10);
for i = 1:10
arr{i} = sparse([], [], [], 1000, 1000);
end
Upvotes: 1