If I execute the following code in MATLAB:
x = mod(1:16,2) == 0; sx = sparse(x)
I get a sparse boolean matrix with the entries
(1, 2) -> 1
(1, 4) -> 1
(1, 6) -> 1
(1, 8) -> 1
(1, 10) -> 1
(1, 12) -> 1
(1, 14) -> 1
(1, 16) -> 1
Now I save this matrix with different mat-versions like this:
save('v4.mat', 'sx', '-v4')
save('v6.mat', 'sx', '-v6')
save('v7.mat', 'sx', '-v7')
save('v73.mat', 'sx', '-v7.3')
If I try accessing the content using the matdump tool, it only works with the v73.mat file. The others seem to get the data type wrong.
matdump.exe -d v4.mat
MAT V4 data type error
Name: sx
Rank: 2
Dimensions: 9 x 3
Class Type: Sparse Array
Data Type: IEEE 754 double-precisionmatdump.exe -d v6.mat
Name: sx
Rank: 2
Dimensions: 1 x 16
Class Type: Sparse Array (logical)
Data Type: IEEE 754 double-precision
{
(1,2) 7.7486e-304
}matdump.exe -d v7.mat
Name: sx
Rank: 2
Dimensions: 1 x 16
Class Type: Sparse Array (logical)
Data Type: IEEE 754 double-precision
{
(1,2) 7.7486e-304
}matdump.exe -d v73.mat
Name: sx
Rank: 2
Dimensions: 1 x 16
Class Type: Sparse Array (logical)
Data Type: 8-bit, unsigned integer
{
(1,2) 1
(1,4) 1
(1,6) 1
(1,8) 1
(1,10) 1
(1,12) 1
(1,14) 1
(1,16) 1
}
I do not support sparse arrays in version 4 MAT files.
I want to write a test case for the sparse logical variables, but I have attached a patch that fixes the issue. I will actually blame this one on MATLAB. In the MAT file it says the data is written as double values, but they are actually 8-bit ints. I used R2014a to generate my data file. Can you tell me what version you are using? At least for now, I assume if the sparse array is logical, the data is written as int8. Would you please test on your end and let me know if there are any issues? I will commit this once I get a test case written for it.
I am using MATLAB R2014a as well.
Applying the patch fixed the problem, so thank you for the quick help.
Should be fixed by commit [7af9e7].
Related
Commit: [7af9e7]