How can I sort a large sparse matrix and then export the result in matlab? -


I have to process a large sparse matrix whose size is 6004 * 17842 (doctor * word) to find the function () An attempt has been made to achieve his rows, pillars and values ​​and the result is avoided. But the conditions have not been resolved in each document, can I suggest a way to sort the matrix and export the sort results?

It seems like you have a question about how search Returns non-zero entries in rare matrix. For example, consider the following MBAB commands

  m = 6004; N = 17842; A = spand (M, N, 0.000001); [I, j, x] = search (a);  

Because MetLab stores its sparse matrix in Compressed Spurs column format, non-zero entries returned by Find are sorted by column. That is, the first code in i , j and x vectors contain all non-zero entries, then all non-zero in the second column Entries, and so on. Since your matrix is ​​a word x document matrix, it means that you first see all the conditions in the document, then all the conditions in another document, and so on. The row (period) entries within each column (s) are sorted. Maybe you want to sort non-zero entries by line (rank). That is, you want to see all the documents in which there are first posts, after which all the documents contain the second term, and so on. It's just so easy that when you change find :

  [doc, term, val] = find (a ');  

To export the sorted entries to a text file, you can do something like this:

  dlmwrite ('doc-term.txt', [Doc word wal]);  

Comments