diff --git a/+types/+untyped/@DataStub/load_mat_style.m b/+types/+untyped/@DataStub/load_mat_style.m index a6fa1f16..12d281ca 100644 --- a/+types/+untyped/@DataStub/load_mat_style.m +++ b/+types/+untyped/@DataStub/load_mat_style.m @@ -34,7 +34,14 @@ , iDimension, dimensionSize); end - if isscalar(userSelection) && ~ischar(userSelection{1}) + if isscalar(userSelection) && isempty(userSelection{1}) + % If userselection (indices) is empty, get the first element of this + % DataStub and try to return an empty representation of that type. + data = obj.load_mat_style(1); + data = getEmptyRepresentation(data); + return + + elseif isscalar(userSelection) && ~ischar(userSelection{1}) % linear index into the fast dimension. orderedSelection = unique(userSelection{1}); @@ -187,4 +194,19 @@ indexKeyIndex(indexKeyIndexNextIndex) = indexKeyIndex(indexKeyIndexNextIndex) + 1; indexKeyIndex((indexKeyIndexNextIndex+1):end) = 1; end +end + + +function emptyInstance = getEmptyRepresentation(nonEmptyInstance) + try + emptyInstance = nonEmptyInstance; + emptyInstance(:) = []; + catch ME + switch ME.identifier + case 'MATLAB:table:LinearSubscript' + emptyInstance(:, :) = []; + otherwise + error('Not implemented for value of type: "%s"', class(nonEmptyInstance)) + end + end end \ No newline at end of file