From 068564628dd7c2612b7c9b2c75db2255d2738303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Mon, 14 Oct 2013 18:17:32 +0200 Subject: [PATCH] Added condition (input must be a string) in isyearly, isquaterly, ismonthly and isweekly functions. --- matlab/utilities/dates/ismonthly.m | 6 +++++- matlab/utilities/dates/isquaterly.m | 6 +++++- matlab/utilities/dates/isweekly.m | 6 +++++- matlab/utilities/dates/isyearly.m | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/matlab/utilities/dates/ismonthly.m b/matlab/utilities/dates/ismonthly.m index dd028706b..7d3a60f65 100644 --- a/matlab/utilities/dates/ismonthly.m +++ b/matlab/utilities/dates/ismonthly.m @@ -25,7 +25,11 @@ function b = ismonthly(str) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -b = ~isempty(regexp(str,'^-?[0-9]*[Mm]([1-9]|1[0-2])$')); +if ischar(str) + b = ~isempty(regexp(str,'^-?[0-9]*[Mm]([1-9]|1[0-2])$')); +else + b = 0; +end %@test:1 %$ diff --git a/matlab/utilities/dates/isquaterly.m b/matlab/utilities/dates/isquaterly.m index 223859b59..92b1c6dc2 100644 --- a/matlab/utilities/dates/isquaterly.m +++ b/matlab/utilities/dates/isquaterly.m @@ -25,7 +25,11 @@ function b = isquaterly(str) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -b = ~isempty(regexp(str,'^-?[0-9]*[Qq][1-4]$')); +if ischar(str) + b = ~isempty(regexp(str,'^-?[0-9]*[Qq][1-4]$')); +else + b = 0; +end %@test:1 %$ diff --git a/matlab/utilities/dates/isweekly.m b/matlab/utilities/dates/isweekly.m index 550c463d5..ea7eca992 100644 --- a/matlab/utilities/dates/isweekly.m +++ b/matlab/utilities/dates/isweekly.m @@ -25,7 +25,11 @@ function b = isweekly(str) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -b = ~isempty(regexp(str,'^-?[0-9]*[Ww]([1-9]|[1-4][0-9]|5[0-2])$')); +if ischar(str) + b = ~isempty(regexp(str,'^-?[0-9]*[Ww]([1-9]|[1-4][0-9]|5[0-2])$')); +else + b = 0; +end %@test:1 %$ diff --git a/matlab/utilities/dates/isyearly.m b/matlab/utilities/dates/isyearly.m index 1af8d778b..ef56c46b9 100644 --- a/matlab/utilities/dates/isyearly.m +++ b/matlab/utilities/dates/isyearly.m @@ -25,7 +25,11 @@ function b = isyearly(str) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -b = ~isempty(regexp(str,'^-?[0-9]*[YyAa]$')); +if ischar(str) + b = ~isempty(regexp(str,'^-?[0-9]*[YyAa]$')); +else + b = 0; +end %@test:1 %$