Can I convert CRS and CSC sparse matrices to MATLAB sparse matrices?
9 views (last 30 days)
Show older comments
MathWorks Support Team
on 14 May 2020
Edited: MathWorks Support Team
on 3 Feb 2025
I have data stored in the CRS and CSC formats in MATLAB arrays, and I want to use them as "sparse" matrices in MATLAB with the sparse matrix operations.
How can I convert from CRS and CSC to MATLAB sparse matrices? I understand that internally MATLAB stores sparse matrices in the CSC format. To access the specific details of how MATLAB handles sparse matrices, please execute the following command in the MATLAB R2020a command window to view the relevant documentation:
>> web(fullfile(docroot, 'matlab/ref/sparse.html'))
Accepted Answer
MathWorks Support Team
on 17 Jan 2025
Edited: MathWorks Support Team
on 3 Feb 2025
Unfortunately at this time, the only way to create MATLAB sparse matrices is with 1-indexed, [row, column, vector] triplets, which are not how CRS and CSC are formatted.
Once you have the data in this accepted format, you can use the (row, column, value) vectors as input to the "spconvert" and "sparse" MATLAB functions. To access the documentation for these functions in MATLAB R2020a, execute the following command in the command window:
>> web(fullfile(docroot, 'matlab/ref/spconvert.html'))
Similarly, for the "sparse" function documentation, use this command in MATLAB R2020a:
>> web(fullfile(docroot, 'matlab/ref/sparse.html'))
For information on the current release, please visit the following link to search for the required details:
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!