From 069d87aa5f3b547c4c1c5fb3712a455ca3584efd Mon Sep 17 00:00:00 2001 From: Alberto Cuadra Lara Date: Tue, 11 Apr 2023 16:27:47 +0200 Subject: [PATCH] Update: miscellaneous --- gui/utils/gui_seeker_exact_value.m | 9 ++++++--- gui/utils/gui_seeker_value.m | 12 ++++++++---- utils/create_cell_ntimes.m | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/gui/utils/gui_seeker_exact_value.m b/gui/utils/gui_seeker_exact_value.m index 4c414942d..1387c2e9b 100644 --- a/gui/utils/gui_seeker_exact_value.m +++ b/gui/utils/gui_seeker_exact_value.m @@ -8,14 +8,17 @@ index = index + 1; seekIndex = strcmp(ListValues{index}, seekValue); end + if index value = ListValues{index}; % Value found in ListValues else value = []; % Value not found in ListValues end + catch ME - errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ... - ME.stack(1).name, ME.stack(1).line, ME.message); - fprintf('%s\n', errorMessage); + errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ... + ME.stack(1).name, ME.stack(1).line, ME.message); + fprintf('%s\n', errorMessage); end + end \ No newline at end of file diff --git a/gui/utils/gui_seeker_value.m b/gui/utils/gui_seeker_value.m index 3812c69bc..091b25b32 100644 --- a/gui/utils/gui_seeker_value.m +++ b/gui/utils/gui_seeker_value.m @@ -6,18 +6,22 @@ value = []; return end + for i = length(ListValues):-1:1 seekIndex(i) = startsWith(ListValues{i}, seekValue, 'IgnoreCase', false); end + if any(seekIndex) value = ListValues(seekIndex); % Value found in ListValues else value = []; % Value not found in ListValues end + catch ME - errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ... - ME.stack(1).name, ME.stack(1).line, ME.message); - fprintf('%s\n', errorMessage); - uiwait(warndlg(errorMessage)); + errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ... + ME.stack(1).name, ME.stack(1).line, ME.message); + fprintf('%s\n', errorMessage); + uiwait(warndlg(errorMessage)); end + end \ No newline at end of file diff --git a/utils/create_cell_ntimes.m b/utils/create_cell_ntimes.m index 23a905793..d6ceced39 100644 --- a/utils/create_cell_ntimes.m +++ b/utils/create_cell_ntimes.m @@ -1,5 +1,6 @@ function C = create_cell_ntimes(varargin) % Create cell array with the same item n-times + if nargin > 2 value = varargin{1}; C = varargin{3}; @@ -8,7 +9,7 @@ n = varargin{2}; C = cell(1, n); else - error('Error sub-pass fuinction @create_cell_ntimes inside @guiReactantsValueChanged'); + error('Error sub-pass function @create_cell_ntimes inside @guiReactantsValueChanged'); end % Set value