MATLAB: How to add elements to a sparse matrix

sparse full spconvert full

Dear community,
I have a sparse matrix S with the dimensions 2028 rows by 14809 columns. I would like to turn S into a full matrix F with the dimensions 2028 rows by 14927 columns. This means that I would like to define a 2028×14927 matrix of zeros first and then fill it with the elements of S in the correct place.
Here is a small example: Below you can see the first 4 elements of the sparse matrix:
(1,1) 1
(1,2) 2
(1,3) 2
(1,6) 8
...
I would like to turn into something like this:
(1,1) 1
(1,2) 2
(1,3) 2
(1,4) 0
(1,5) 0
(1,6) 8
...
Any ideas? Thank you! Paul

Best Answer

F=full(S)
F=[F,zeros(2028,14927-14809)];
Related Question