By the information in the question :
In vector cell arrays it is usually the first vector used as a sparse
matrix dimensionThe second element is a scalar specifying the default value of the
sparse matrixThe other vectors are used to specify the location and the value of
the element in the sparse matrix , i.e.[i, j, x]
wherei
,j
is the location
in the matrix andx
is the value of the element.
So the program is simply :
function matrix=sparse2matrix(cellvec);
matrix=zeros(cellvec{1})+cellvec{2};
for i=3:length(cellvec)
matrix(cellvec{i}(1,1),cellvec{i}(1,2))=cellvec{i}(3);
end
0
solved How can do I make a sparse matrix using cell arrays in MATLAB?