Matlab and Scipy sparse matrix formats are compatible. You need to get the data, indices and matrix matrix size in Scipy and use them to create a sparse matrix in Matlab. Here is an example:
from scipy.sparse import csr_matrix from scipy import array
What prints:
(0, 0) 1 (0, 2) 2 (1, 2) 3 (2, 0) 4 (2, 1) 5 (2, 2) 6
Use the values ββm, n, s, i and j from Python to create a matrix in Matlab:
m = 3; n = 4; s = [1, 2, 3, 4, 5, 6]; % Index from 1 in Matlab. i = [0, 0, 1, 2, 2, 2] + 1; j = [0, 2, 2, 0, 1, 2] + 1; S = sparse(i, j, s, m, n, m*n)
Which gives the same matrix, only indexed from 1.
(1,1) 1 (3,1) 4 (3,2) 5 (1,3) 2 (2,3) 3 (3,3) 6