Mercurial > hg > ltpda
view testing/utp_1.1/utps/mfir/utp_mfir_mfir.m @ 44:409a22968d5e default
Add unit tests
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Tue, 06 Dec 2011 18:42:11 +0100 |
parents | |
children |
line wrap: on
line source
% UTP_MFIR_MFIR a set of UTPs for the mfir/mfir method % % M Hewitson 06-08-08 % % $Id: utp_mfir_mfir.m,v 1.37 2011/08/22 05:37:13 hewitson Exp $ % % <MethodDescription> % % The mfir method of the mfir class constructs MFIR objects. % % </MethodDescription> function results = utp_mfir_mfir(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'mfir'; mthd = 'mfir'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test objects [firhp,firlp,firbp,firbr,firpzm,firao,firv,firm] = get_test_objects_mfir; % Exception list for the UTPs: [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples(); % Run the tests results = [results utp_01]; % getInfo call results = [results utp_02]; % Vector input results = [results utp_03]; % Matrix input results = [results utp_04]; % List input results = [results utp_05]; % Test with mixed input results = [results utp_06]; % Test history is working with empty constructor results = [results utp_07]; % Test history is working with copy constructor results = [results utp_08]; % Test history is working with MAT file constructor results = [results utp_09]; % Test history is working with XML file constructor results = [results utp_10]; % Test history is working with AO constructor (default) results = [results utp_11]; % Test history is working with struct constructor results = [results utp_12]; % Test history is working with pzmodel-object constructor results = [results utp_13]; % Test history is working with plist(filename) constructor results = [results utp_14]; % Test history is working with plist(hostname) constructor results = [results utp_15]; % Test history is working with plist(type) constructor results = [results utp_16]; % Test history is working with plist(pzmodel) constructor results = [results utp_17]; % Test history is working with plist(plist) constructor results = [results utp_18]; % Test history is working with plist(a) constructor results = [results utp_19]; % Test history is working with plist(AO) constructor results = [results utp_20]; % Test history is working with plist(AO) constructor results = [results utp_21]; % Test history is working with plist(AO) constructor results = [results utp_22]; % Test history is working with AO + plist constructor results = [results utp_23]; % Test history is working with conn+Id constructor results = [results utp_24]; % Test history is working with pzmodel + plist constructor results = [results utp_25]; % Test history is working with a + fs constructor disp('Done.'); disp('******************************************************'); elseif nargin == 1 % Check for UTP functions if strcmp(varargin{1}, 'isutp') results = 1; elseif strcmpi(varargin{1}, 'needs repository') results = 2; else results = 0; end else error('### Incorrect inputs') end %% UTP_01 % <TestDescription> % % Tests that the getInfo call works for this method. % % </TestDescription> function result = utp_01 % <SyntaxDescription> % % Test that the getInfo call works for no sets, all sets, and each set % individually. % % </SyntaxDescription> try % <SyntaxCode> % Call for no sets io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']); % Call for all sets io(2) = eval([class '.getInfo(''' mthd ''')']); % Call for each set for kk=1:numel(io(2).sets) io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']); end % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that getInfo call returned an minfo object in all cases. % 2) Check that all plists have the correct parameters. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % check we have minfo objects if isa(io, 'minfo') prefs = getappdata(0, 'LTPDApreferences'); dwin = char(prefs.getMiscPrefs.getDefaultWindow); %%% SET 'None' if ~isempty(io(1).sets), atest = false; end if ~isempty(io(1).plists), atest = false; end %%% Check all Sets if ~any(strcmpi(io(2).sets, 'Default')), atest = false; end if ~any(strcmpi(io(2).sets, 'From XML File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From MAT File')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Repository')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Standard Type')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Pzmodel')), atest = false; end if ~any(strcmpi(io(2).sets, 'From A')), atest = false; end if ~any(strcmpi(io(2).sets, 'From AO')), atest = false; end if ~any(strcmpi(io(2).sets, 'From Built-in Model')), atest = false; end if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end %%%%%%%%%% SET 'Default' if io(3).plists.nparams ~= 3, atest = false; end % Check key % Check default value % Check options %%%%%%%%%% SET 'From MAT File' pn = 4; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end %%%%%%%%%% SET 'From XML File' pn = 5; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('filename'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('filename')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('filename'), {''}), atest = false; end %%%%%%%%%% SET 'From Repository' pn = 6; if io(pn).plists.nparams ~= 10, atest = false; end % Check key if ~io(pn).plists.isparam('hostname'), atest = false; end if ~io(pn).plists.isparam('id'), atest = false; end if ~io(pn).plists.isparam('cid'), atest = false; end if ~io(pn).plists.isparam('database'), atest = false; end if ~io(pn).plists.isparam('binary'), atest = false; end if ~io(pn).plists.isparam('username'), atest = false; end if ~io(pn).plists.isparam('password'), atest = false; end % Check default value if ~isEmptyDouble(io(pn).plists.find('id')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('cid')), atest = false; end if ~isequal(io(pn).plists.find('binary'), 'yes'), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('id'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('cid'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('binary'), {'yes', 'no'}), atest = false; end %%%%%%%%%% SET 'From Built-in Model' pn = 7; if io(pn).plists.nparams ~= 4, atest = false; end % Check key if ~io(pn).plists.isparam('built-in'), atest = false; end % Check default value if ~isEmptyChar(io(pn).plists.find('built-in')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('built-in'), {''}), atest = false; end %%%%%%%%%% SET 'From Standard Type' pn = 8; if io(pn).plists.nparams ~= 10, atest = false; end % Check key if ~io(pn).plists.isparam('name'), atest = false; end if ~io(pn).plists.isparam('description'), atest = false; end if ~io(pn).plists.isparam('type'), atest = false; end if ~io(pn).plists.isparam('fc'), atest = false; end if ~io(pn).plists.isparam('gain'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('order'), atest = false; end if ~io(pn).plists.isparam('iunits'), atest = false; end if ~io(pn).plists.isparam('ounits'), atest = false; end % Check default value if ~isequal(io(pn).plists.find('type'), 'lowpass'), atest = false; end if ~isequal(io(pn).plists.find('fc'), [.1 .4]), atest = false; end if ~isequal(io(pn).plists.find('gain'), 1), atest = false; end if ~isequal(io(pn).plists.find('fs'), 1), atest = false; end if ~isequal(io(pn).plists.find('order'), 128), atest = false; end if ~isEmptyChar(io(pn).plists.find('iunits')), atest = false; end if ~isEmptyChar(io(pn).plists.find('ounits')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('type'), {'highpass', 'lowpass', 'bandpass', 'bandreject'}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fc'), {[.1 .4]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('gain'), {1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fs'), {1}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('order'), {128}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('iunits'), {''}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ounits'), {''}), atest = false; end %%%%%%%%%% SET 'From Pzmodel' pn = 9; if io(pn).plists.nparams ~= 7, atest = false; end % Check key if ~io(pn).plists.isparam('pzmodel'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('iunits'), atest = false; end if ~io(pn).plists.isparam('ounits'), atest = false; end % Check default value if ~eq(io(pn).plists.find('pzmodel'), pzmodel(), ple1), atest = false; end if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end if ~isEmptyChar(io(pn).plists.find('iunits')), atest = false; end if ~isEmptyChar(io(pn).plists.find('ounits')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('iunits'), {''}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('ounits'), {''}), atest = false; end %%%%%%%%%% SET 'From A' pn = 10; if io(pn).plists.nparams ~= 7, atest = false; end % Check key if ~io(pn).plists.isparam('a'), atest = false; end if ~io(pn).plists.isparam('fs'), atest = false; end if ~io(pn).plists.isparam('name'), atest = false; end % Check default value if ~isEmptyDouble(io(pn).plists.find('a')), atest = false; end if ~isEmptyDouble(io(pn).plists.find('fs')), atest = false; end if ~isEmptyChar(io(pn).plists.find('name')), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('a'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('fs'), {[]}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('name'), {''}), atest = false; end %%%%%%%%%% SET 'From AO' pn = 11; if io(pn).plists.nparams ~= 10, atest = false; end % Check key if ~io(pn).plists.isparam('ao'), atest = false; end if ~io(pn).plists.isparam('n'), atest = false; end if ~io(pn).plists.isparam('method'), atest = false; end if ~io(pn).plists.isparam('win'), atest = false; end % Check default value if ~eq(io(pn).plists.find('ao'), ao(), ple1), atest = false; end if ~isequal(io(pn).plists.find('n'), 512), atest = false; end if ~isequal(io(pn).plists.find('method'), 'frequency-sampling'), atest = false; end if ~isequal(lower(io(pn).plists.find('win')), lower(dwin)), atest = false; end % Check options if ~isequal(io(pn).plists.getOptionsForParam('n'), {512}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('method'), {'frequency-sampling', 'least-squares', 'Parks-McClellan'}), atest = false; end if ~isequal(io(pn).plists.getOptionsForParam('win'), specwin.getTypes), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_01 %% UTP_02 % <TestDescription> % % Tests that the mfir method works with a vector of MFIR objects as input. % % </TestDescription> function result = utp_02 % <SyntaxDescription> % % Test that the mfir method works with a vector of MFIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = mfir(firv); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the shape of the output MFIRs is the same as the input shape. % 2) Check that each output MFIR is a copy of the input MFIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check we have the correct shape if size(out) ~= size(firv), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(firv(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(firv(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(firv(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_02 %% UTP_03 % <TestDescription> % % Tests that the mfir method works with a matrix of MFIR objects as input. % % </TestDescription> function result = utp_03 % <SyntaxDescription> % % Test that the mfir method works with a matrix of MFIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = mfir(firm); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the shape of the output MFIRs is the same as the input shape. % 2) Check that each output MFIR is a copy of the input MFIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check we have the correct number of outputs if size(out) ~= size(firm), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(firm(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(firm(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(firm(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_03 %% UTP_04 % <TestDescription> % % Tests that the mfir method works with a list of MFIR objects as input. % % </TestDescription> function result = utp_04 % <SyntaxDescription> % % Test that the mfir method works with a list of MFIR objects as input. % % </SyntaxDescription> try % <SyntaxCode> out = mfir(firhp, firlp, firbp); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the number of elements in 'out' is the same of the % number in the input. % 2) Check that each output MFIR is a copy of the input MFIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; firin = [firhp, firlp, firbp]; if stest % <AlgoCode> % Check we have the correct number of outputs if numel(out) ~= 3, atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(firin(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(firin(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(firin(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_04 %% UTP_05 % <TestDescription> % % Tests that the mfir method works with a mix of different shaped MFIRs as % input. % % </TestDescription> function result = utp_05 % <SyntaxDescription> % % Test that the mfir method works with a mix of different shaped MFIRs as % input. % % </SyntaxDescription> try % <SyntaxCode> out = mfir(firhp,firv,firbr,firm,firlp); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the number of elements in 'out' is the same of the % number in the input. % 2) Check that each output MFIR is a copy of the input MFIR. % 3) Check that the copy have an additional history step. % % </AlgoDescription> atest = true; firin = [firhp, reshape(firv, 1, []), firbr, reshape(firm, 1, []), firlp]; if stest % <AlgoCode> % Check we have the correct number of outputs if numel(out) ~= 3+numel(firv)+numel(firm), atest = false; end % Check that the output is a copy. for ii = 1:numel(out) % Check that the output is the same except the history if ~eq(firin(ii), out(ii), ple3), atest = false; end % Check the history if ~eq(firin(ii).hist, out(ii).hist.inhists), atest = false; end % Change the output to make sure that it is a 'real' copy out(ii).setDescription('my desc'); if eq(firin(ii), out(ii), ple3), atest = false; end end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_05 %% UTP_06 % <TestDescription> % % Tests that the mfir method properly applies history. % % </TestDescription> function result = utp_06 % <SyntaxDescription> % % Test that the result of applying the mfir method can be processed back. % % </SyntaxDescription> try % <SyntaxCode> out = mfir(firlp); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the method rebuild produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_06 %% UTP_07 % <TestDescription> % % Tests that the mfir method properly applies history to the copy constructor. % % </TestDescription> function result = utp_07 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % Test the constructor with a different number of inputs. % % </SyntaxDescription> try % <SyntaxCode> out1 = mfir(firhp); out2 = mfir(firhp, firlp); out3 = mfir(firhp, firlp, firbp); out1.setName('my name'); out2(1).setName('my name'); out2(2).setName('my name'); out3(1).setName('my name'); out3(2).setName('my name'); out3(3).setName('my name'); mout = rebuild(out1); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the original objects are not changed by the setter function % 3) Check that the method rebuild produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' % It is the method 'setName' because we set it in above if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end % Check next to the last step in the history of 'out' if ~strcmp(out1.hist.inhists.methodInfo.mname, 'mfir'), atest = false; end % Check the originals if strcmp(firhp, 'my name'), atest = false; end if strcmp(firlp, 'my name'), atest = false; end if strcmp(firbp, 'my name'), atest = false; end % Check the rebuilt object if ~eq(mout, out1, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_07 %% UTP_08 % <TestDescription> % % Tests that the mfir method properly applies history to the read % MAT-file constructor. % % </TestDescription> function result = utp_08 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> filename = 'fir.mat'; fir = mfir(firlp); save(fir, filename); out = mfir(filename); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Reading a file doesn't add additionally history steps if ~eq(out, fir, ple2), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> delete(filename); else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_08 %% UTP_09 % <TestDescription> % % Tests that the mfir method properly applies history to the read % XML-file constructor. % % </TestDescription> function result = utp_09 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> filename = 'fir.xml'; amat = mfir(firm); save(amat, filename); out = mfir(filename); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the shape % 2) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 3) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the shape of the rebuilt object if size(amat) ~= size(out), atest = false; end % Check the algorithm for kk = 1:numel(out) % Check the last step in the history of 'out' if ~strcmp(out(kk).hist.methodInfo.mname, 'mfir'), atest = false; end % Reading a file doesn't add additionally history steps if ~eq(out(kk), amat(kk), ple1), atest = false; end end % Check the rebuilt object for kk = 1:numel(out) if ~eq(mout(kk), out(kk), ple2), atest = false; end end % </AlgoCode> delete(filename); else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_09 %% UTP_10 % <TestDescription> % % Tests that the mfir method properly applies history to the AO constructor. % % </TestDescription> function result = utp_10 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. Use % the default values (method = 'frequency-sampling'). % % </SyntaxDescription> try % <SyntaxCode> fs = 1000; f = linspace(0, fs/2, 1000); xx = randn(1000,1); plao = plist('type', 'fsdata', 'xvals', f, 'yvals', xx, 'fs', fs); a1 = ao(plao); out = mfir(a1); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Get the default values and compare this values with the output. f = a1.x; xx = abs(a1.y); pl = mfir.getInfo('mfir', 'From AO').plists; N = pl.find('N'); win = specwin(pl.find('win'), N+1); ffm = f/(fs/2); mtaps = fir2(N, ffm, xx, win.win); if out.fs ~= fs, atest = false; end if out.ntaps ~= length(mtaps), atest = false; end if out.a ~= mtaps, atest = false; end if out.gd ~= (length(mtaps)+1)/2, atest = false; end % Check that the AO history appends to the mfir history if ~eq(out.hist.inhists, a1.hist), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_10 %% UTP_11 % <TestDescription> % % Tests that the mfir method properly applies history to the struct constructor. % % </TestDescription> function result = utp_11 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> sfirhp = struct(firhp); sfirhp.iunits = struct(firhp.iunits); sfirhp.ounits = struct(firhp.ounits); sfirhp.hist = struct(firhp.hist); out1 = mfir(struct(firpzm)); out2 = mfir(sfirhp); mout1 = rebuild(out1); mout2 = rebuild(out2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the output is a MFIR object if ~isa(out1,'mfir'), atest = false; end if ~isa(out2,'mfir'), atest = false; end % Check the last step in the history of 'out' if ~strcmp(out1.hist.methodInfo.mname, 'setName'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'setName'), atest = false; end % Check the rebuilt object if ~eq(mout1, out1, ple2), atest = false; end if ~eq(mout2, out2, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_11 %% UTP_12 % <TestDescription> % % Tests that the mfir method properly applies history to the pzmodel constructor. % % </TestDescription> function result = utp_12 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz^2'), unit('V^2')); out = mfir(pzm); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check that the output is a MFIR object if ~isa(out,'mfir'), atest = false; end % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_12 %% UTP_13 % <TestDescription> % % Tests that the mfir method properly applies history to the % plist(filename) constructor. % % </TestDescription> function result = utp_13 % <SyntaxDescription> % % Test that the output can be processed back to an m-file. % % </SyntaxDescription> try % <SyntaxCode> filename1 = 'fir.xml'; filename2 = 'fir.mat'; f1 = mfir(firpzm); f2 = mfir(firlp); save(f1, filename1); save(f2, filename2); out1 = mfir(plist('filename', filename1)); out2 = mfir(plist('filename', filename2)); rout1 = out1.rebuild; rout2 = out2.rebuild; % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the save method doesn't change the input object % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the input object of the save method if ~eq(f1, mfir(firpzm), ple1), atest = false; end if ~eq(f2, mfir(firlp), ple1) , atest = false; end % Check the last history step of 'out' (load)c if ~strcmp(out1.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'mfir'), atest = false; end % The load doesn't have two additionally history steps (save + load) if ~eq(out1, f1, ple1), atest = false; end if ~eq(out2, f2, ple1), atest = false; end % Run 'test.m' and check the result if ~eq(rout1, out1, ple2), atest = false; end if ~eq(rout2, out2, ple2), atest = false; end % </AlgoCode> % delete test file delete(filename1) delete(filename2) else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_13 %% UTP_14 % <TestDescription> % % Tests that the MFIR method properly applies history to the % plist(conn) constructor. % % </TestDescription> function result = utp_14 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> conn = utpGetConnection; sinfo.conn = conn; sinfo.experiment_title = 'utp_mfir_mfir_14: submit mfir vector'; sinfo.experiment_description = 'utp_mfir_mfir_14: &description'; sinfo.analysis_description = '<utp_mfir_mfir_14>'; sinfo.quantity = 'none'; sinfo.keywords = 'none'; sinfo.reference_ids = ''; sinfo.additional_comments = 'none'; sinfo.additional_authors = 'no one'; plForAutoTest = plist('no dialog', true, 'use selector', false); ids = submit(firv, sinfo, plForAutoTest); out = mfir(plist('hostname', utpGetHostname, 'database', utpGetDatabase, 'conn', conn, 'id', ids)); % </SyntaxCode> % Close connection utpCloseConnection(conn); stest = true; catch err disp(err.message) % Close connection utpCloseConnection(conn); stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' for kk = 1:numel(out) if ~strcmp(out(kk).hist.methodInfo.mname, 'mfir'), atest = false; end end % Check data values if ~eq(out, firv, ple3), atest = false; end % Rebuild object and check the result % % This test is in an automatic test not possible because the repository % asks for username and password. % % Manually tested by: Ingo Diepholz % Test date: 08.12.2008 % Status: success % % rout = rebuild(out); % if ~eq(rout, out, ple3), atest = false; end % % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_14 %% UTP_15 % <TestDescription> % % Tests that the MFIR method properly applies history to the % plist(type) constructor. % % </TestDescription> function result = utp_15 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pl1 = plist('type', 'lowpass'); pl2 = plist('type', 'highpass'); pl3 = plist('type', 'bandpass'); pl4 = plist('type', 'bandreject'); plerr = plist('type', 'wrong name'); % Use different values to the default values g = 2; fs = 1000; fc = 60; fcb = [50 100]; order = 32; win = specwin('Hamming', order+1); pl = plist('fs', fs, 'fc', fc, 'order', order, 'gain', g); plb = plist('fs', fs, 'fc', fcb, 'order', order, 'gain', g); out1 = mfir(combine(pl1, pl)); out2 = mfir(combine(pl2, pl)); out3 = mfir(combine(pl3, plb)); out4 = mfir(combine(pl4, plb)); rout1 = rebuild(out1); rout2 = rebuild(out2); rout3 = rebuild(out3); rout4 = rebuild(out4); try % Negative test: Should throw an error mfir(plerr); stest = false; catch stest = true; end % </SyntaxCode> catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out1.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out3.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out4.hist.methodInfo.mname, 'mfir'), atest = false; end % Check 'lowpass' filter a = g.*fir1(order, 2*fc/fs, 'low', win.win); if ~isequal(out1.a, a), atest = false; end if ~isequal(out1.fs, fs), atest = false; end if ~isequal(out1.gd, (length(a)-1)/2), atest =false; end if ~strcmp(out1.name, 'lowpass'), atest = false; end % Check 'highpass' filter a = g.*fir1(order, 2*fc/fs, 'high', win.win); if ~isequal(out2.a, a), atest = false; end if ~isequal(out2.fs, fs), atest = false; end if ~isequal(out2.gd, (length(a)-1)/2), atest =false; end if ~strcmp(out2.name, 'highpass'), atest = false; end % Check 'bandpass' filter a = g.*fir1(order, 2.*fcb/fs, 'bandpass', win.win); if ~isequal(out3.a, a), atest = false; end if ~isequal(out3.fs, fs), atest = false; end if ~isequal(out3.gd, (length(a)-1)/2), atest =false; end if ~strcmp(out3.name, 'bandpass'), atest = false; end % Check 'bandpass' filter a = g.*fir1(order, 2.*fcb/fs, 'stop', win.win); if ~isequal(out4.a, a), atest = false; end if ~isequal(out4.fs, fs), atest = false; end if ~isequal(out4.gd, (length(a)-1)/2), atest =false; end if ~strcmp(out4.name, 'bandreject'), atest = false; end % Rebuild object and check the result if ~eq(rout1, out1, ple2), atest = false; end if ~eq(rout2, out2, ple2), atest = false; end if ~eq(rout3, out3, ple2), atest = false; end if ~eq(rout4, out4, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_15 %% UTP_16 % <TestDescription> % % Tests that the MFIR method properly applies history to the % plist(pzmodel) constructor. % % </TestDescription> function result = utp_16 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V')); pl = plist('pzmodel', pzm, 'fs', 500); out = mfir(pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check the next to the last step in the history. % It must be the history of the pole/zero model (here 'pzmodel') % Since we changed the constructors, the history no longer contains the pzmodel % since we put the pzmodel in the plist. %if ~strcmp(out.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end % Check values if ~isequal(out.fs, 500), atest = false; end if ~eq(out.iunits, unit('Hz')), atest = false; end if ~eq(out.ounits, unit('V')), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_16 %% UTP_17 % <TestDescription> % % Tests that the MFIR method properly applies history to the % plist(<plist-object>) constructor. % % </TestDescription> function result = utp_17 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pzm = pzmodel(1, [pz(1) pz(200)], pz(50), unit('V'), unit('Hz')); pl = plist('pzmodel', pzm, 'fs', 500); out1 = mfir(plist('plist', pl)); out2 = mfir(plist('plist', plist())); % empty plist mout1 = rebuild(out1); mout2 = rebuild(out2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out1' if ~strcmp(out1.hist.methodInfo.mname, 'mfir'), atest = false; end % Check the next to the last step in the history. % It must be the history of the partial fraction model (here 'pzmodel') if ~strcmp(out1.hist.inhists.methodInfo.mname, 'pzmodel'), atest = false; end % Check values if ~isequal(out1.fs, 500), atest = false; end if ~eq(out1.iunits, unit('V')), atest = false; end if ~eq(out1.ounits, unit('Hz')), atest = false; end % Check the last step in the history of 'out2' if ~strcmp(out2.hist.methodInfo.mname, 'mfir'), atest = false; end % Check the next to the last step in the history. if ~isempty(out2.hist.inhists), atest = false; end % Rebuild object and check the result if ~eq(out1, mout1, ple1), atest = false; end if ~eq(out2, mout2, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_17 %% UTP_18 % <TestDescription> % % Tests that the MFIR method properly applies history to the a constructor. % % </TestDescription> function result = utp_18 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> pl = plist('a', [1 2 3], 'fs', 123); out = mfir(pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check values if ~isequal(out.fs, 123), atest = false; end if ~isequal(out.a, [1 2 3]), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_18 %% UTP_19 % <TestDescription> % % Tests that the mfir method properly applies history to the plist(AO) constructor. % % </TestDescription> function result = utp_19 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. Use % the method 'frequency-sampling'. % % </SyntaxDescription> try % <SyntaxCode> fs = 500; f = linspace(0, fs/2, fs); xx = randn(fs,1); plao = plist('type', 'fsdata', 'xvals', f, 'yvals', xx, 'fs', fs); a1 = ao(plao); win1 = specwin('kaiser', 32, 100); win2 = specwin('BH92', 32); N = 64; plfir1 = plist('ao', a1, 'method', 'frequency-sampling', 'win', win1, 'N', N); plfir2 = plist('ao', a1, 'method', 'frequency-sampling', 'win', win2, 'N', N); out1 = mfir(plfir1); out2 = mfir(plfir2); mout1 = rebuild(out1); mout2 = rebuild(out2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out1.hist.methodInfo.mname, 'mfir'), atest = false; end if ~strcmp(out2.hist.methodInfo.mname, 'mfir'), atest = false; end % Get the default values and compare this values with the output. f = a1.x; xx = abs(a1.y); ffm = f/(fs/2); newwin = specwin('kaiser', N+1, 100); mtaps1 = fir2(N, ffm, xx, newwin.win); newwin = specwin('BH92', N+1); mtaps2 = fir2(N, ffm, xx, newwin.win); if out1.fs ~= fs, atest = false; end if out1.ntaps ~= length(mtaps1), atest = false; end if out1.a ~= mtaps1, atest = false; end if out1.gd ~= (length(mtaps1)+1)/2, atest = false; end if out2.fs ~= fs, atest = false; end if out2.ntaps ~= length(mtaps2), atest = false; end if out2.a ~= mtaps2, atest = false; end if out2.gd ~= (length(mtaps2)+1)/2, atest = false; end % Check that the AO history appends to the mfir history if ~eq(out1.hist.inhists, a1.hist), atest = false; end if ~eq(out2.hist.inhists, a1.hist), atest = false; end % Check the rebuilt object if ~eq(mout1, out1, ple2), atest = false; end if ~eq(mout2, out2, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_19 %% UTP_20 % <TestDescription> % % Tests that the mfir method properly applies history to the plist(AO) constructor. % % </TestDescription> function result = utp_20 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. Use % the method 'least-squares'. % % </SyntaxDescription> try % <SyntaxCode> fs = 500; f = linspace(0, fs/2, fs); xx = randn(fs,1); plao = plist('type', 'fsdata', 'xvals', f, 'yvals', xx, 'fs', fs); a1 = ao(plao); win = specwin('BH92', 32); N = 64; try plfir = plist('ao', a1, 'method', 'least-squares', 'win', win, 'N', N); out = mfir(plfir); mout = rebuild(out); stest = false; catch stest = true; end % </SyntaxCode> catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) At the moment throws this method an error. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_20 %% UTP_21 % <TestDescription> % % Tests that the mfir method properly applies history to the plist(AO) constructor. % % </TestDescription> function result = utp_21 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. Use % the method 'Parks-McClellan'. % % </SyntaxDescription> try % <SyntaxCode> fs = 500; f = linspace(0, fs/2, fs); xx = randn(fs,1); plao = plist('type', 'fsdata', 'xvals', f, 'yvals', xx, 'fs', fs); a1 = ao(plao); win = specwin('BH92', 32); N = 64; try plfir = plist('ao', a1, 'method', 'Parks-McClellan', 'win', win, 'N', N); out = mfir(plfir); mout = rebuild(out); stest = false; catch stest = true; end % </SyntaxCode> catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) At the moment throws this method an error. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_21 %% UTP_22 % <TestDescription> % % Tests that the mfir method properly applies history to the AO + plist constructor. % % </TestDescription> function result = utp_22 % <SyntaxDescription> % % Test that the output can be processed back with the 'rebuild' method. Use % the method 'frequency-sampling'. % % </SyntaxDescription> try % <SyntaxCode> fs = 500; f = linspace(0, fs/2, fs); xx = randn(fs,1); plao = plist('type', 'fsdata', 'xvals', f, 'yvals', xx, 'fs', fs); a1 = ao(plao); win = specwin('kaiser', 32, 100); N = 64; plfir = plist('method', 'frequency-sampling', 'win', win, 'N', N); out = mfir(a1, plfir); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' % corresponds to 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Get the default values and compare this values with the output. f = a1.x; xx = abs(a1.y); ffm = f/(fs/2); newwin = specwin('kaiser', N+1, 100); mtaps = fir2(N, ffm, xx, newwin.win); if out.fs ~= fs, atest = false; end if out.ntaps ~= length(mtaps), atest = false; end if out.a ~= mtaps, atest = false; end if out.gd ~= (length(mtaps)+1)/2, atest = false; end % Check that the AO history appends to the mfir history if ~eq(out.hist.inhists, a1.hist), atest = false; end % Check the rebuilt object if ~eq(mout, out, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_22 %% UTP_23 % <TestDescription> % % Tests that the MFIR method properly applies history to the conn+Id constructor. % % </TestDescription> function result = utp_23 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> conn = utpGetConnection sinfo.conn = conn; sinfo.experiment_title = 'utp_mfir_mfir_23: submit mfir'; sinfo.experiment_description = 'utp_mfir_mfir_23: description'; sinfo.analysis_description = 'utp_mfir_mfir_23'; sinfo.quantity = 'none'; sinfo.keywords = 'none'; sinfo.reference_ids = ''; sinfo.additional_comments = 'none'; sinfo.additional_authors = 'no one'; plForAutoTest = plist('no dialog', true, 'use selector', false); [ids] = submit(firao, sinfo, plForAutoTest); out = mfir(conn, ids); % </SyntaxCode> % Close connection utpCloseConnection(conn); stest = true; catch err disp(err.message) % Close connection utpCloseConnection(conn); stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that re-running the 'test.m' file produces the same object % as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check data values if ~eq(out,firao, ple3), atest = false; end % Check the history except the additional 'submit' + 'retrieve' steps if ~eq(out.hist.inhists, firao.hist), atest = false; end % % This test is in an automatic test not possible because the repository % asks for username and password % % Manual test by: Ingo Diepholz % Test date: 08.12.2008 % Status: success % % rout = rebuild(out); % if ~eq(mout, out, ple3), atest = false; end % % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_23 %% UTP_24 % <TestDescription> % % Tests that the MFIR method properly applies history to the % pole/zero model + plist object constructor. % % </TestDescription> function result = utp_24 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> ps = [pz(1) pz(200)]; zs = pz(50); pzm = pzmodel(1, ps, zs, unit('Hz'), unit('V')); pl = plist('fs', 123); out = mfir(pzm, pl); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check values if ~isequal(out.fs, 123), atest = false; end if ~eq(out.iunits, unit('Hz')), atest = false; end if ~eq(out.ounits, unit('V')), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_24 %% UTP_25 % <TestDescription> % % Tests that the MFIR method properly applies history to the % a + fs object constructor. % % </TestDescription> function result = utp_25 % <SyntaxDescription> % % Test that the output can be processed back with the rebuild method. % % </SyntaxDescription> try % <SyntaxCode> a = [1 2 3]; fs = 123.123; out = mfir(a,fs); rout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the last entry in the history of 'out' corresponds to % 'mfir'. % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'mfir'), atest = false; end % Check values if ~isequal(out.fs, 123.123), atest = false; end if ~isequal(out.a, [1 2 3]), atest = false; end % Rebuild object and check the result if ~eq(rout, out, ple1), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_25 end