The behavior you are experiencing is expected behavior. When creating a column consisting of a cell array with empty strings, these are actually treated as empty char row vectors rather than empty strings. Since these are treated as empty char row vectors, they are treated as a missing value. Because of this, there is no "group" to assign them to when passing the variable 'X' to the 'GroupingVariables' parameter, so the entire row is excluded.
A workaround would be to convert the variable 'X' from a cell array to a string array, as follows:
tblInput = table({'';'';''},[10;20;30],[40;50;60],[7, 1;8, 2;9,3]);
tblInput.Properties.VariableNames = {'X','Y','Z','Quantity'};
tblInput.X = string(tblInput.X);
strGroupingVariables = {'X','Y','Z'};
tblEmpty = varfun(@nansum,tblInput,'GroupingVariables',strGroupingVariables, 'InputVariables', {'Quantity'})
result:
tblEmpty =
3×5 table
X Y Z GroupCount nansum_Quantity
__ __ __ __________ _______________
"" 10 40 1 8
"" 20 50 1 10
"" 30 60 1 12
Best Answer
"h5read" returns data as a cell array to ensure that variable-sized datasets, such as datasets containing variable-sized strings, are handled in a consistent and predictable way. The cell array output of "h5read" can be converted into a matrix (if the data is not variable-sized) using the "cell2mat" command. It is possible for "h5read" to display characters that are not seen with the "hdf5read" command because "h5read" will output all the characters in a string, while "hdf5read" will terminate a string when it encounters a null character (null characters are represented as spaces when displayed in MATLAB). It is possible to replicate this behavior using the command:
where "data" is the output of "h5read", converted into a character array.