From ca4601bd1c7a5df33f62339d7c2edb5b70ebcb56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 11 Jan 2022 17:44:24 +0100
Subject: [PATCH] dyntable: fix column width calculation in case of minus sign
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

By the same token, improve the logical expression for determining whether all
values are infinite (it was nevertheless giving the right result, because an
“all()” is implicit when an array of booleans is passed to an “if” statement).
---
 matlab/dyntable.m | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/matlab/dyntable.m b/matlab/dyntable.m
index e9ed038f6e..6ecf237e8c 100644
--- a/matlab/dyntable.m
+++ b/matlab/dyntable.m
@@ -15,7 +15,7 @@ function dyntable(options_, title, headers, labels, values, label_width, val_wid
 % OUTPUTS
 % none
 
-% Copyright (C) 2002-2018 Dynare Team
+% Copyright (C) 2002-2022 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -46,12 +46,12 @@ label_format_leftbound  = sprintf('%%-%ds', label_width);
 
 
 % Set width of other columns
-if all(~isfinite(values))
+if all(all(~isfinite(values)))
     values_length = 4;
 else
     values_length = max(ceil(max(max(log10(abs(values(isfinite(values))))))),1)+val_precis+1;
 end
-if any(values) < 0 %add one character for minus sign
+if any(any(values < 0)) %add one character for minus sign
     values_length = values_length+1;
 end
 headers_length = cellofchararraymaxlength(headers(2:end));
@@ -82,4 +82,4 @@ end
 
 for i=1:size(values,1)
     disp([sprintf(label_format_leftbound, labels{i}) sprintf(value_format, values(i,:))])
-end
\ No newline at end of file
+end
-- 
GitLab