How can I visualize the data of a sparse matrix using a vector

The way I’m doing it, the index values appear all mixed up in the code:

EX:
v = matopen(“index.mat”);
index= read(v, “v”);
close(v);

x = (list[index])

How did you create index.mat in Matlab? Can you upload it (or a similar minimal file with the same format)? What is list?

But perhaps most importantly, what are you trying to do? Why don’t you just save the sparse matrix as a sparse matrix in Matlab? Example:

Matlab:

>> M = sprandn(10000,10000,0.0001);
>> save('test.mat', 'M');

Julia:

julia> using MAT

julia> d = matread("test.mat")
Dict{String, Any} with 1 entry:
  "M" => sparse([2297, 3220, 9009, 2298, 6641, 3586, 5225, 1655, 4198, 9512  …  8606, 2691, 2919, 6280, 7576…

julia> d["M"]
10000×10000 SparseArrays.SparseMatrixCSC{Float64, Int64} with 9999 stored entries:
⢢⢄⣭⡈⡾⡅⣰⡰⡁⠪⢴⣺⣟⢶⢦⣺⠲⡰⣊⣝⣵⢲⣈⣳⠆⣇⡠⢋⡥⣃⣶⢒⠓⠣⢑⣍⣢⣳⢹⣆⡡⣳⠊⡦⣾⠭⢘⣫⣽⢾⣢⡞
⡔⣆⡒⣭⢏⡋⣹⣨⡻⢫⣡⣸⠹⢵⣾⢵⢻⢺⢬⣶⣇⣘⣙⡴⡟⡷⣯⣧⢶⢿⣎⢆⡞⣈⡝⣣⣽⢝⡝⠻⡿⠶⠂⢿⠾⢣⡟⣿⢦⡻⢜⠫
⣘⣳⢁⠰⠸⡾⣴⠷⣿⠿⠖⠑⢼⡞⡅⣣⣺⡯⢊⢺⣞⢙⢱⢾⢳⣞⣻⣺⢤⣵⣺⢪⣙⢼⡮⣾⢊⢿⣾⢥⠇⢌⠳⡟⣎⢯⣿⡟⡮⢽⡂⣻
⠘⡽⠰⡮⣷⡔⠐⠞⣿⣟⣯⣖⡫⡯⢻⣮⡌⢹⢫⢕⡎⡽⢽⣏⣑⣔⣽⣝⢭⡟⢷⡗⠻⡑⣐⢳⢷⡮⠟⣇⡷⣫⡜⣥⣶⣿⡤⣟⡢⣞⠦⡌
⢺⡃⣻⣺⣯⡟⠻⢊⢑⢫⣟⣂⣩⠿⣰⢴⢔⡿⠾⣈⢝⢎⢢⣱⢰⢹⣽⡵⡦⣾⠸⡹⠾⣖⣢⠇⡁⣴⣟⠞⣏⢵⡱⣢⣟⡵⣫⢚⡹⠞⢶⣄
⡐⡺⠜⣇⠙⡨⡶⣃⢿⣤⢫⡓⢻⡡⣝⣳⣏⡸⡻⡚⡂⣩⢷⡺⣥⡻⡅⣕⢭⣕⢔⣥⠾⢧⣟⣟⡦⣶⠣⣫⠯⣟⡝⣾⢦⣓⡕⣿⢱⠫⠜⡃
⠋⡝⡫⠤⢽⡊⠵⡘⣥⣚⡃⡪⣞⣷⣸⢃⣎⣏⢝⣘⢪⠑⡛⢷⠃⠓⣼⡿⡹⢳⣖⢯⠽⠭⢯⢾⡴⣹⡷⡯⢻⢵⣿⡃⡎⠧⢹⢪⠿⣽⣛⡶
⠽⠝⡪⠷⣪⣀⡷⢜⣗⢁⣹⠖⣨⡾⢆⣱⣝⣉⣩⡌⢺⡴⡺⠩⠖⢉⣖⣏⣧⠫⠺⢹⣓⡯⢼⡭⡤⠓⠻⣿⣵⡟⠝⣙⣴⢏⠷⡼⣣⣋⣶⠽
⠖⢵⣂⢄⣬⡟⠯⣇⠌⣯⣣⢸⢻⣊⣥⡽⠂⣥⣿⣬⢍⠏⢐⡓⣿⣹⡫⣸⣡⣥⣾⣹⢷⣾⡯⡽⠥⣩⢛⡺⢟⡻⢎⡇⣺⡗⣐⠊⡿⢙⠕⠖
⡂⢦⣪⣯⠺⣪⡋⢼⣏⡧⣬⣕⣞⡸⢫⡟⡵⣖⣞⣿⣛⣸⡓⢌⣼⢻⢆⢠⣰⡝⣮⡼⢚⠡⣇⡬⡍⢿⡪⣠⣢⢽⣒⢢⡜⡭⢾⣅⡑⢏⡲⠏
⣴⢟⢋⢾⡮⢗⡫⣮⠝⢥⡖⣝⠝⡸⣷⡼⢶⣿⢧⣹⣱⢗⢋⡖⠖⢒⢴⠴⡻⢱⡙⣘⢿⢓⢳⢷⡁⢹⡫⠝⠷⠻⢯⣿⡶⡬⣬⠚⡇⢸⣶⡇
⢸⣗⡺⢾⣾⠵⢞⣺⡒⣏⢸⡾⣝⢟⢿⢻⣇⡙⢝⡕⣯⡵⣎⡊⠍⡮⡨⡺⢻⠿⢾⣩⣋⡺⣷⡼⣹⠫⢳⢿⣏⢑⠝⣳⡿⣫⢱⢐⠂⢔⡼⡦
⢴⢩⢩⣟⡳⣮⠢⢷⠁⣨⠭⢊⣬⢰⡯⢯⣛⣐⢭⡆⡴⠱⣍⣸⠆⣴⢎⢯⣯⡑⣫⡬⣹⢹⣰⣿⡫⣪⡙⡟⠕⣧⠔⠂⣆⠝⣿⣍⣲⣶⡲⣒
⡕⣾⢠⣵⡶⢿⡌⣵⢜⣾⢗⡋⢒⢥⡺⣝⣋⣣⣀⣽⢿⣭⢸⣻⢛⢛⢶⢴⡮⣕⢢⣟⠏⣭⠯⣍⠽⣗⣮⡔⣿⢔⢾⡕⡆⣕⠗⡥⣜⢸⣗⢮
⠫⢾⡵⡗⠄⣽⣬⡽⣍⡒⢀⣍⡷⠿⡯⠯⢳⢝⢝⣯⡼⡲⢝⡋⣯⠡⡪⢭⣸⡸⡫⣾⠝⣢⡛⢾⡏⢊⠺⣴⣿⣲⣾⣧⣧⡎⡳⣭⡛⢅⣻⠒
⢮⠿⣿⠭⢯⡍⡸⢒⣝⡼⣿⠫⢾⣉⠇⠭⡷⡟⢯⡡⣖⠿⣓⢽⡹⣜⢈⣛⡗⡳⣽⣇⢇⢸⠯⣛⣄⠩⠳⣩⡚⡗⣿⣢⡭⡵⣹⡩⣟⡵⢩⢕
⣔⢓⣯⣜⣟⠭⡋⠓⢽⡳⣽⢖⣟⢡⠋⠻⣷⣗⡛⢛⢼⣞⣖⡕⣮⠳⣷⣢⣗⠤⢜⡚⢉⣿⢾⣿⣣⠩⡾⣦⡿⣶⡿⣲⣝⡫⡹⢝⡏⠺⡺⠑
⡥⣱⣏⡬⣋⡙⣸⢊⠯⢵⣱⢻⢼⡖⢒⡼⢌⣯⡳⡵⡵⣿⡙⣳⢟⡔⢊⡻⢮⢫⡿⣵⠾⡧⠮⠦⡳⣠⡎⢈⠿⢴⢯⡗⢜⡮⡧⡼⠻⠗⣪⡩
⢻⠷⡩⡧⢓⣴⡷⡙⡞⣾⠔⢷⠙⣊⣹⣘⣩⣑⠣⡵⣤⡚⣜⡷⡵⡋⡷⠵⢹⣪⢿⣚⣪⣍⣭⢲⣽⢝⣪⣷⣥⣆⢢⡮⣬⢣⠟⡵⢏⠯⠶⡥
⢻⣛⣷⣩⣎⣭⣿⢷⡜⢼⢯⡚⢧⣾⠐⠯⣉⡯⠚⡫⣆⣇⢟⠛⡖⢗⣎⠘⣿⢑⢗⠵⡺⣗⡪⢯⣦⢧⣱⣛⡻⡦⣖⢣⣋⣤⡋⡋⣚⠻⢋⠧
⢤⢿⡳⣽⠘⢛⢟⣼⣵⠳⣻⢯⣓⣸⡷⡕⡷⠳⠾⣫⢃⢭⣜⢎⠵⣵⢰⣽⢐⡹⣳⢼⡳⠢⢹⣝⠇⡾⡰⡺⣝⠉⡒⣊⣯⡎⣨⠽⣶⢞⢚⠬
⢛⢯⡾⠗⢀⠳⣫⡿⣣⡽⣴⡟⣗⢚⢛⣠⣦⣏⣺⢢⠷⣟⠖⣳⡮⠕⢧⣘⣬⣟⠒⡺⢿⣂⠭⡮⡳⠴⡿⠞⡷⠿⠕⢝⢻⣥⡹⢃⣝⡾⢽⣆
⢺⡜⡿⣧⣏⣠⣹⢽⣚⣯⡼⢿⡲⣋⢵⢐⣴⢷⢣⢴⢺⣲⢱⢜⢇⠏⣰⣚⣝⠴⣴⡟⡽⣏⡊⢖⣿⣟⣶⢧⢞⢱⢽⣐⡽⢋⣑⣶⣞⣪⢞⣖
⣋⡷⣺⣟⣏⢻⢒⢣⣙⢲⠳⡟⡼⣊⢯⡽⢗⢴⢵⣺⠛⡵⠴⢷⠿⢅⠬⠟⣝⡛⢤⠼⡱⣿⡏⣟⣍⣖⢺⣖⢣⢴⢩⢤⣛⠂⡝⡿⣶⠵⢽⡪
⠼⡇⣆⣿⠗⣡⠜⣧⢻⢻⢗⣋⣺⣍⠌⣻⣐⣯⣿⢿⣪⢦⠪⡼⠕⣞⣕⣛⠟⠝⠇⠸⢕⡬⠷⡦⡧⢥⡧⣟⠿⣛⡛⡿⠮⣹⢿⣷⠻⡮⣪⠕
⡑⠨⠦⠗⠢⡘⠿⠏⡢⣏⠼⢾⢎⢼⢷⢛⣮⠟⠓⠎⠥⠳⡄⠝⣆⠓⠾⠻⡨⣊⡸⢜⢩⠦⡱⡪⢨⠏⣗⠞⢷⠭⠪⠠⠦⠱⣬⢃⡭⢻⡯⢃
1 Like

It is a sparse matrix from Matlab yes, I managed to solve the problem this way:

The vector with the indexes was like this:
println(size(index))
(6770, 1)

I did like this:
index = reshape(index, 6770, );

x= (list[index])