Open Nelson-numerical-software opened 5 years ago
Is this only the case for v7.3 MAT-files or can you also reproduce when saved with -v6 or -v7?
same problem with v6 or v7
save using matio works but not an original .mat file
Can you please attach all three file here. Thanks.
>> A = cell(1);
>> B = {[]};
>> isequal(A, B)
ans =
1
>> whos
Name Size Bytes Class
A 1x1 4 cell array
B 1x1 60 cell array
ans 1x1 1 logical array
Though the two variable are equal, they are not. The difference is in the size. Variable A is en empty cell, variable B is a cell containing an empty array (of type double). This is also what matdump reports:
$ matdump -f whos -d empty_cell.mat
Name Size Bytes Class
A 1x1 4 mxCELL_CLASS
B 1x1 60 mxCELL_CLASS
$ matdump -d empty_cell.mat A
Name: A
Rank: 2
Class Type: Cell Array
{
Empty
}
$ matdump -d empty_cell.mat B
Name: B
Rank: 2
Class Type: Cell Array
{
}
For variable A there simply is no data type information available. That is why you get MAT_T_UNKNOWN. Changing it to MAT_T_DOUBLE by default does not seem straight.
But I have to admit that this kind of empty variable is not yet covered by the test. In matio_test_cases.m we have the following cases for empty cells
%% Cell-Array Variables
var51 = {}; % or var51 = cell(0);
var52 = {[] single([]) int64([]) uint64([]) int32([]) uint32([]) int16([]) uint16([]) int8([]) uint8([])};
Tested with 1.5.13:
load with matio:
elementMatVar->class_type with k = 0 returns: MAT_C_EMPTY and not MAT_C_DOUBLE (expected) elementMatVar->data_type MAT_T_UNKNOWN
same code with a value works: