Skip to content

Commit

Permalink
Simplify fix for load_mat_style
Browse files Browse the repository at this point in the history
  • Loading branch information
ehennestad committed Nov 2, 2024
1 parent 536375e commit 387a51f
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions +types/+untyped/@DataStub/load_mat_style.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,14 @@
points = cell(length(dataDimensions), 1);

if isscalar(dataDimensions)
if isMATLABReleaseOlderThanR2024b()
% Pass. Scalar size input to ind2sub was supported until R2024b.
else
% Starting in MATLAB R2024b, the input argument for the size
% of an array in ind2sub must be a vector of positive integers
% with two or more elements. This fix replicates the behavior of
% older MATLAB versions, where it was assumed that the a scalar
% size referred to the row dimension. For scalar dimensions
% (i.e., row or column vectors), we can still assume this
% to be true in matnwb.
dataDimensions = [dataDimensions, 1];
end
% Starting in MATLAB R2024b, the input argument for the size
% of an array in ind2sub must be a vector of positive integers
% with two or more elements. This fix replicates the behavior of
% older MATLAB versions, where it was assumed that the a scalar
% size referred to the row dimension. For scalar dimensions
% (i.e., row or column vectors), we can still assume this
% to be true in matnwb.
dataDimensions = [dataDimensions, 1];
end

[points{:}] = ind2sub(dataDimensions, orderedSelection);
Expand Down Expand Up @@ -204,11 +200,3 @@
indexKeyIndex((indexKeyIndexNextIndex+1):end) = 1;
end
end

function tf = isMATLABReleaseOlderThanR2024b()
if exist('isMATLABReleaseOlderThan', 'file') == 2
tf = isMATLABReleaseOlderThan('R2024b');
else
tf = true; % isMATLABReleaseOlderThan was introduced in R2020b
end
end

0 comments on commit 387a51f

Please sign in to comment.