I have this sparse matrix of size lets say N x M.
I want to write the data into a file such that each line represents each row. Starts with the number of non zero entries in that row. Followed by the indices where it is non zero space their values, like this:
186 0:1 1:34 2:234 ...
123 0:23 2:23 6:303
Where 186 means the number of nonzeros in the first row. 0 represents the first column and its corresponding value 1. This is followed by the 1st column value 34 for the first row and so on.
Similarly for the second row, 123 is the number of non zero values. 0 represents the first column and its corresponding value 23 and so on.
How can I do this efficiently in matlab?