From 09f3a20e462efbad96b20e6d6f687d06472097ec Mon Sep 17 00:00:00 2001 From: Sameeh Jubran Date: Sun, 8 Aug 2021 13:42:12 +0300 Subject: [PATCH] Use try catch instead of isempty() to check if variable exists If DisplayName doesn't exist for some reason we might get the following error [0]. Simply use try catch to store the name. [0] - Unrecongnized field name "DisplayName". Signed-off-by: Sameeh Jubran --- plotly/plotlyfig_aux/handlegraphics/updateArea.m | 6 +++--- plotly/plotlyfig_aux/handlegraphics/updatePatch.m | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plotly/plotlyfig_aux/handlegraphics/updateArea.m b/plotly/plotlyfig_aux/handlegraphics/updateArea.m index b3e019ad..286bbe7d 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updateArea.m +++ b/plotly/plotlyfig_aux/handlegraphics/updateArea.m @@ -113,10 +113,10 @@ function updateArea(obj,areaIndex) %-------------------------------------------------------------------------% %-area name-% -if ~isempty(area_data.DisplayName); - obj.data{areaIndex}.name = area_data.DisplayName; -else +try obj.data{areaIndex}.name = area_data.DisplayName; +catch + obj.data{areaIndex}.name = ''; end %-------------------------------------------------------------------------% diff --git a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m index b89fffa2..6f2b9523 100644 --- a/plotly/plotlyfig_aux/handlegraphics/updatePatch.m +++ b/plotly/plotlyfig_aux/handlegraphics/updatePatch.m @@ -135,10 +135,10 @@ %---------------------------------------------------------------------% %-patch name-% - if ~isempty(patch_data.DisplayName); - obj.data{patchIndex}.name = patch_data.DisplayName; - else + try obj.data{patchIndex}.name = patch_data.DisplayName; + catch + obj.data{patchIndex}.name = ''; end %---------------------------------------------------------------------%