From ac7f34a30a6b5e498caf4e367ed928d2d192526b Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Fri, 18 Aug 2023 14:24:47 +0200 Subject: [PATCH] Modified output_table to be created from cell array using cell2table() instead of array2table(). This extracts the contents of each cell, facilitating later column based filtering ops. --- import/read_hdf5_as_table.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/import/read_hdf5_as_table.m b/import/read_hdf5_as_table.m index 12af873..e38f6b1 100644 --- a/import/read_hdf5_as_table.m +++ b/import/read_hdf5_as_table.m @@ -58,9 +58,9 @@ end % Construct cell array with table data, where each row denotes a group, and % the columns are either datasets or attributes in the given group. -tmp = {}; +tmp = cell(num_rows,num_cols); % {}; idx = []; -group_columns = {}; +group_columns = {}; for i = 1 : num_rows disp(['Begin construction of row:',INFO.Groups(i).Name]) @@ -86,7 +86,7 @@ for i = 1 : num_rows else % no data type conversion is performed convert_func = @(x) x; end - + tmp{i,j} = convert_func(h5readatt(filename,INFO.Groups(i).Name, Name)); if i < 2 @@ -115,5 +115,12 @@ end [~, idx_perm] = sort(idx,'ascend'); varNames = [dataset_columns,group_columns]; -output_table = array2table(tmp(:,idx_perm), 'VariableNames', varNames(idx_perm)); + +% Create output_table from cell array using cell2table. This as opposed to +% array2table extract the content of its cells, which facilitates filtering +% operations based on table columns/vars. + +%output_table = array2table(tmp(:,idx_perm), 'VariableNames', varNames(idx_perm)); +output_table = cell2table(tmp(:,idx_perm), 'VariableNames', varNames(idx_perm)); +