From 4add96e8bbefb8ff5b9dc94fb51c0de0369c63c0 Mon Sep 17 00:00:00 2001 From: p147685 Date: Mon, 30 Mar 2020 07:29:01 +0200 Subject: [PATCH] --- resources/BSM_Class/BSM.m | 213 +++++++++++++++++++++++++---- resources/BSM_Class/TestBSMClass.m | 41 ++++-- 2 files changed, 218 insertions(+), 36 deletions(-) diff --git a/resources/BSM_Class/BSM.m b/resources/BSM_Class/BSM.m index 6f5cca0..40f4aca 100644 --- a/resources/BSM_Class/BSM.m +++ b/resources/BSM_Class/BSM.m @@ -5,9 +5,12 @@ classdef BSM1 + id = 'BSM:Monitor:TooManyInputs'; + msg= sprintf('Too many inputs given.\n Use: \t obj.Monitor\n\tobj.Monitor(true)\n\tobj.monitor(false)\n'); + throw(MException(id,msg)) + end + if numel(varargin)==0 + obj.MonitorState=xor(obj.MonitorState,true); + else + if ~islogical(varargin{1}) + id = 'BSM:Monitor:InputIsNotLogical'; + msg= sprintf('Input is not of type logical\n'); + throw(MException(id,msg)) + end + obj.MonitorState=varargin{1}; + end + end function Calc(obj,varargin) % obj.calc to apply calculate to all SPM.mat files % obj.calc(n) to calculated the nth SPM.mat file @@ -97,6 +118,35 @@ classdef BSM %% exception block %NB these exception has not been tested properly by the - if (SPM.xBF.order ~=1 ) + if (SPM.xBF.order ~=1 ) %#ok<*NODEF> %TestBSMClass program %throw an error. The calling function should properly %handle the error. @@ -190,7 +240,7 @@ classdef BSM %will create an error @@ -15,7 +15,7 @@ catch ME rethrow(ME); end end -%% +%% initialize properly clear B B=BSM('type',1,'Acfl',[],'SPMs',{}); %% set SPMs validity check @@ -34,19 +34,44 @@ catch ME rethrow(ME) end end -B.SPMs=tmp; -%% set Type check -try - B.Type='onzin'; %gives an error +%% +try + B.SPMs={'SPM.mat';'onzin.mat'}; %provides an error if file does not exist catch ME - if strcmpi(ME.identifier,'BSM:Type:invalid') + if strcmpi(ME.identifier,'BSM:SetSPMs:FileNotFound') + disp('error properly handled') + disp(ME); + else + rethrow(ME) + end +end +B.SPMs=tmp; +%% set Prefix check +try + B.Prefix=""; %gives an error +catch ME + if strcmpi(ME.identifier,'BSM:SetPrefix:InvalidInput') disp('error properly handled') disp(ME); else rethrow(ME) end end -%% +B.Prefix='bs' +%% set Clean check +try + B.Clean=""; %gives an error +catch ME + if strcmpi(ME.identifier,'BSM:SetClean:InvalidType') + disp('error properly handled') + disp(ME); + else + rethrow(ME) + end +end +disp(B.Clean) +B.Clean=true; +%% Check Type set try B.Type=0; %gives an error catch ME