From eb79af4220e891162247a86a923b68c69ea68aa3 Mon Sep 17 00:00:00 2001 From: Qiyuan Feng Date: Mon, 11 May 2026 19:42:34 -0400 Subject: [PATCH] mlrnum2str.m: fix nanmax not exist problem in 2023b or later --- mrUtilities/MatlabUtilities/mlrnum2str.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mrUtilities/MatlabUtilities/mlrnum2str.m b/mrUtilities/MatlabUtilities/mlrnum2str.m index cfae15d8f..8b103b9a8 100644 --- a/mrUtilities/MatlabUtilities/mlrnum2str.m +++ b/mrUtilities/MatlabUtilities/mlrnum2str.m @@ -64,7 +64,11 @@ elseif length(size(num)) == 2 num = num'; % compute maxnumdigits on the left side of decimal excluding inf and nan - maxnumdigits = length(sprintf('%i',floor(nanmax(abs(num(~isinf(num(:)))))))); + if exist('nanmax') %#ok new version of MATLAB does not have function nanmax + maxnumdigits = length(sprintf('%i',floor(nanmax(abs(num(~isinf(num(:)))))))); + else + maxnumdigits = length(sprintf('%i',floor(max(abs(num(~isinf(num(:)))),[],1,'omitnan')))); + end % if there is an inf or nan, account for that if any(isnan(num(:))) | any(isinf(num(:))) % if sigfigs is zero then Inf and Nan cannot line up with decimal, so shift over by a space