Mercurial > hg > ltpda
view testing/utp_1.1/utps/mfir/utp_mfir_resp.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_RESP a set of UTPs for the mfir/resp method % % M Hewitson 06-08-08 % % $Id: utp_mfir_resp.m,v 1.6 2010/03/15 15:57:06 ingo Exp $ % % <MethodDescription> % % The resp method of the mfir class Make a frequency response of the filter. % For a command with no output variables plots the method the result into a % diagram. % % </MethodDescription> function results = utp_mfir_resp(varargin) % Check the inputs if nargin == 0 % Some keywords class = 'mfir'; mthd = 'resp'; results = []; disp('******************************************************'); disp(['**** Running UTPs for ' class '/' mthd]); disp('******************************************************'); % Test MFIR objects [fir1,fir2,fir3,fir4,fir5,fir6,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 results = [results utp_07]; % Test the modify call works results = [results utp_08]; % Test input data shape == output data shape results = [results utp_09]; % Test output of the data results = [results utp_10]; % Test with f = ao.y results = [results utp_11]; % Test with f results = [results utp_12]; % Test with f1, f2 and nf results = [results utp_13]; % Test with f1, f2 and nf AND 'scale' results = [results utp_14]; % Test serial bank results = [results utp_15]; % Test parallel bank % Make surethat all figures are closed close all; disp('Done.'); disp('******************************************************'); elseif nargin == 1 % Check for UTP functions if strcmp(varargin{1}, 'isutp') results = 1; 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') %%% 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, 'List')), atest = false; end if ~any(strcmpi(io(2).sets, 'Range')), atest = false; end if numel(io(2).plists) ~= numel(io(2).sets), atest = false; end %%%%%%%%%% SET 'List' if io(3).plists.nparams ~= 2, atest = false; end % Check key if ~io(3).plists.isparam('f'), atest = false; end if ~io(3).plists.isparam('bank'), atest = false; end % Check default value if ~isEmptyDouble(io(3).plists.find('f')), atest = false; end if ~isequal(io(3).plists.find('bank'), 'none'), atest = false; end % Check options if ~isequal(io(3).plists.getOptionsForParam('f'), {[]}), atest = false; end if ~isequal(io(3).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), atest = false; end %%%%%%%%%% SET 'Range' if io(4).plists.nparams ~= 5, atest = false; end % Check key if ~io(4).plists.isparam('f1'), atest = false; end if ~io(4).plists.isparam('f2'), atest = false; end if ~io(4).plists.isparam('nf'), atest = false; end if ~io(4).plists.isparam('scale'), atest = false; end if ~io(4).plists.isparam('bank'), atest = false; end % Check default value if ~isEmptyDouble(io(4).plists.find('f1')), atest = false; end if ~isEmptyDouble(io(4).plists.find('f2')), atest = false; end if ~isequal(io(4).plists.find('nf'), 1000), atest = false; end if ~isequal(io(4).plists.find('scale'), 'log'), atest = false; end if ~isequal(io(4).plists.find('bank'), 'none'), atest = false; end % Check options if ~isequal(io(4).plists.getOptionsForParam('f1'), {[]}), atest = false; end if ~isequal(io(4).plists.getOptionsForParam('f2'), {[]}), atest = false; end if ~isequal(io(4).plists.getOptionsForParam('nf'), {1000}), atest = false; end if ~isequal(io(4).plists.getOptionsForParam('scale'), {'lin', 'log'}), atest = false; end if ~isequal(io(4).plists.getOptionsForParam('bank'), {'none', 'serial', 'parallel'}), 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 resp method works with a vector of MFIR objects as input. % % </TestDescription> function result = utp_02 % <SyntaxDescription> % % Test that the resp method works for a vector of MFIR objects as input. % Test the method with an output and with no output (a diagram must appear) % % </SyntaxDescription> try % <SyntaxCode> % Make sure that all figures are closed. close all; resp(firv); out = resp(firv); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Test the right number of lines in the diagram. % 2) Check that the number of elements in 'out' is the same as in 'firv' % 3) Check that each output MFIR contains the correct data. % % </AlgoDescription> THRESHOLD = 1e-12; atest = true; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); % Check that the diagram have the same number of lines as the output % object if max(cellfun('size', lines, 1)) ~= numel(firv), atest = false; end % Check the number of output objects. if ~isequal(size(out), size(firv)), atest = false; end % Check each output against the default values for f1, f2 and nf for ii = 1:numel(out) nf = find(mfir.getInfo('resp', 'Range').plists, 'nf'); % Default values always from the first filter f1 = firv(ii).fs/1000; f2 = firv(ii).fs/2-1/nf; if ~isa(out(ii), 'ao'), atest = false; end if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end if out(ii).x(1) ~= f1, atest = false; end if abs(out(ii).x(end)-f2)>THRESHOLD, atest = false; end if numel(out(ii).x) ~= nf, 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 resp method works with a matrix of MFIR objects as input. % % </TestDescription> function result = utp_03 % <SyntaxDescription> % % Test that the resp method works for a matrix of MFIR objects as input. % Test the method with an output and with no output (a diagram must appear) % % </SyntaxDescription> try % <SyntaxCode> % Make sure that all figures are closed. close all; firmat = [fir1, fir2, fir3; fir4, fir5, fir6]; resp(firmat); out = resp(firmat); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Test the right number of lines in the diagram. % 2) Check that the number of elements in 'out' is the same as in 'firmat' % 3) Check that each output MFIR contains the correct data. % % </AlgoDescription> atest = true; THRESHOLD = 1e-12; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); % Check that the diagram have the same number of lines as the output % object if max(cellfun('size', lines, 1)) ~= numel(firmat), atest = false; end % Check the number of output objects. if ~isequal(size(out), size(firmat)), atest = false; end % Check each output against the default values for f1, f2 and nf for ii = 1:numel(out) % Default values always from the first filter nf = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1 = firmat(ii).fs/1000; f2 = firmat(ii).fs/2-1/nf; if ~isa(out(ii), 'ao'), atest = false; end if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end if out(ii).x(1) ~= f1, atest = false; end if abs(out(ii).x(end)-f2)>THRESHOLD, atest = false; end if numel(out(ii).x) ~= nf, 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 resp method works with a list of MFIR objects as input. % % </TestDescription> function result = utp_04 % <SyntaxDescription> % % Test that the resp method works for a list of MFIR objects as input. % Test the method with an output and with no output (a diagram must appear) % % </SyntaxDescription> try % <SyntaxCode> close all; resp(fir1,fir2,fir3); out = resp(fir1,fir2,fir3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Test the right number of lines in the diagram. % 2) Check that the number of elements in 'out' is the same as in 'firmat' % 3) Check that each output MFIR contains the correct data. % % </AlgoDescription> atest = true; firin = [fir1,fir2,fir3]; THRESHOLD = 1e-15; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); % Check that the diagram have the same number of lines as the output % object if max(cellfun('size', lines, 1)) ~= numel(firin), atest = false; end % Check the number of output objects. if ~isequal(size(out), size(firin)), atest = false; end % Check each output against the default values for f1, f2 and nf for ii = 1:numel(out) % Default values always from the first filter nf = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1 = firin(ii).fs/1000; f2 = firin(ii).fs/2-1/nf; if ~isa(out(ii), 'ao'), atest = false; end if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end if out(ii).x(1) ~= f1, atest = false; end if abs(out(ii).x(end)-f2)>THRESHOLD, atest = false; end if numel(out(ii).x) ~= nf, 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 resp method works with a mix of different shaped MFIR % objects as input. % % </TestDescription> function result = utp_05 % <SyntaxDescription> % % Test that the resp method works with an input of matrices and vectors % and single MFIR objects. Test the method with an output and with no % output (a diagram must appear) % % </SyntaxDescription> try % <SyntaxCode> close all; firmat = [fir5, fir3, fir2; fir1, fir5, fir3]; resp(fir1,firv,fir2,firmat,fir3); out = resp(fir1,firv,fir2,firmat,fir3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Test the right number of lines in the diagram. % 2) Check that the number of elements in 'out' is the same as in 'firmat' % 3) Check that each output MFIR contains the correct data. % % </AlgoDescription> atest = true; firin = [fir1,reshape(firv,1,[]),fir2,reshape(firmat,1,[]),fir3]; THRESHOLD = 1e-12; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); % Check that the diagram have the same number of lines as the output % object if max(cellfun('size', lines, 1)) ~= numel(firin), atest = false; end % Check the number of output objects. if ~isequal(size(out), size(firin)), atest = false; end % Check each output against the default values for f1, f2 and nf for ii = 1:numel(out) % Default values always from the first filter nf = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1 = firin(ii).fs/1000; f2 = firin(ii).fs/2-1/nf; if ~isa(out(ii), 'ao'), atest = false; end if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end if out(ii).x(1) ~= f1, atest = false; end if abs(out(ii).x(end)-f2)>THRESHOLD, atest = false; end if numel(out(ii).x) ~= nf, 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 resp method properly applies history. % % </TestDescription> function result = utp_06 % <SyntaxDescription> % % Test that the result of applying the resp method can be processed back. % % </SyntaxDescription> try % <SyntaxCode> close all; resp(fir5); out = resp(fir5); 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 % 'resp'. % 2) Check that re-built object is the same object as the input. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); x = get(lines{1}, 'XData'); y1 = get(lines{1}, 'YData'); y2 = get(lines{2}, 'YData'); if ~isequal(x, out.x.'), atest = false; end if ~isequal(y2, abs(out.y)'), atest = false; end if ~isequal(y1, utils.math.phase(out.y)'), atest = false; end % Check the last step in the history of 'out' if ~strcmp(out.hist.methodInfo.mname, 'resp'), atest = false; end % Run 'test.m' and check the result 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 modify command plots the response into a diagram. % % </TestDescription> function result = utp_07 % <SyntaxDescription> % % Tests that modify command plots the response into a diagram. % % </SyntaxDescription> try % <SyntaxCode> close all; fir5.resp(); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the response diagram. % % </AlgoDescription> atest = true; THRESHOLD = 1e-12; if stest % <AlgoCode> % Get the current figure. fi = gcf; % Get ALL axes including the legends. ax = get(fi, 'Children'); % Select only the 'axes' with the lines ax = ax(ismember(get(ax(:), 'Tag'), '')); % Get the lines of both axes lines = get(ax(:), 'Children'); x = get(lines{1}, 'XData'); % Default values always from the first filter nf = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1 = fir5(1).fs/1000; f2 = fir5(1).fs/2-1/nf; if x(1) ~= f1, atest = false; end if abs(x(end)-f2)>THRESHOLD, atest = false; end if numel(x) ~= nf, 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> % % Test the shape of the output. % % </TestDescription> function result = utp_08 % <SyntaxDescription> % % Test that the output AO of the resp method keeps the shape of the used % input f vector. % % </SyntaxDescription> try % <SyntaxCode> close all; arow = ao(1:100, linspace(.1, 5, 100)); acol = arow.'; f = linspace(.1, 5, 100); out1 = resp(fir5, plist('f', arow)); out2 = resp(fir5, plist('f', acol)); out3 = resp(fir5, plist('f', f)); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the shape of the data doesn't change. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the shape of the output data if size(out1.data.y,1) ~= 1, atest = false; end if size(out1.data.y,2) == 1, atest = false; end if size(out2.data.y,1) == 1, atest = false; end if size(out2.data.y,2) ~= 1, atest = false; end if size(out3.data.y,1) ~= 1, atest = false; end if size(out3.data.y,2) == 1, atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_08 %% UTP_09 % <TestDescription> % % Check that the resp method pass back the output objects to a list of % output variables or to a single variable. % % </TestDescription> function result = utp_09 % <SyntaxDescription> % % Call the method with a list of output variables and with a single output % variable. Additionaly check that the rebuild method works on the output. % % </SyntaxDescription> try % <SyntaxCode> [o1, o2] = resp(fir5, fir3); o3 = resp(fir5, fir3); mout1 = rebuild(o1); mout2 = rebuild(o2); mout3 = rebuild(o3); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check that the output contains the right number of objects % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the number of outputs if numel(o1) ~=1, atest = false; end if numel(o2) ~=1, atest = false; end if numel(o3) ~=2, atest = false; end % Check the rebuilding of the object if ~eq(o1, mout1, ple2), atest = false; end if ~eq(o2, mout2, ple2), atest = false; end if ~eq(o3, mout3, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_09 %% UTP_10 % <TestDescription> % % Check that the resp method uses the x-data of an input AO for f-vector. % % </TestDescription> function result = utp_10 % <SyntaxDescription> % % Call the method with different method to pass an AO in. % % </SyntaxDescription> try % <SyntaxCode> f1 = .1; f2 = 5; nf = 100; axy = ao(linspace(f1, f2, nf), randn(100,1)); afs = ao(linspace(f1, f2, nf), randn(100,1), plist('type', 'fsdata')); out1 = resp(fir5, plist('f', axy)); out2 = resp(fir5, plist('f', afs)); mout1 = rebuild(out1); mout2 = rebuild(out2); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the output if ~isa(out1, 'ao'), atest = false; end if ~isa(out2, 'ao'), atest = false; end if out1.x(1) ~= f1, atest = false; end if out1.x(end) ~= f2, atest = false; end if numel(out1.x) ~= nf, atest = false; end if out2.x(1) ~= f1, atest = false; end if out2.x(end) ~= f2, atest = false; end if numel(out2.x) ~= nf, atest = false; end % Check the rebuilding of the object if ~eq(out1, mout1, ple2), atest = false; end if ~eq(out2, mout2, 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> % % Check that the resp method uses the specified f-vector to compute the response. % % </TestDescription> function result = utp_11 % <SyntaxDescription> % % Call the method with different method to pass an f-vector in. % % </SyntaxDescription> try % <SyntaxCode> f1 = .1; f2 = 5; nf = 100; f = linspace(f1, f2, nf); out1 = resp(fir5, plist('f', f)); mout1 = rebuild(out1); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the output if ~isa(out1, 'ao'), atest = false; end if out1.x(1) ~= f1, atest = false; end if out1.x(end) ~= f2, atest = false; end if numel(out1.x) ~= nf, atest = false; end % Check the rebuilding of the object if ~eq(out1, mout1, 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> % % Check that the resp method uses the specified f1, f2, and nf to compute the response. % % </TestDescription> function result = utp_12 % <SyntaxDescription> % % Call the method with different method to pass f1, f2, and nf in. % % </SyntaxDescription> try % <SyntaxCode> f1 = .1; f2 = 5; nf = 100; nf2 = 123; out3 = resp(fir5, plist('f1', f1, 'f2', f2, 'nf', nf)); out4 = resp(fir5, plist('f1', f1, 'nf', nf2)); out5 = resp(fir5, plist('f2', f2)); mout3 = rebuild(out3); mout4 = rebuild(out4); mout5 = rebuild(out5); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; T = 1e-12; if stest % <AlgoCode> % Check the output nfd = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1d = fir5.fs/1000; f2d = fir5.fs/2-1/nf; f2d2 = fir5.fs/2-1/nf2; if ~isa(out3, 'ao'), atest = false; end if ~isa(out4, 'ao'), atest = false; end if ~isa(out5, 'ao'), atest = false; end if out3.x(1) ~= f1, atest = false; end if abs(out3.x(end)-f2)>T, atest = false; end if numel(out3.x) ~= nf, atest = false; end if out4.x(1) ~= f1, atest = false; end if abs(out4.x(end)-f2d2)>T, atest = false; end % Default values if numel(out4.x) ~= nf2, atest = false; end if out5.x(1) ~= f1d, atest = false; end % Default values if abs(out5.x(end)-f2)>T, atest = false; end if numel(out5.x) ~= nfd, atest = false; end % Default values % Check the rebuilding of the object if ~eq(out3, mout3, ple2), atest = false; end if ~eq(out4, mout4, ple2), atest = false; end if ~eq(out5, mout5, ple2), 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> % % Check that the resp method uses the specified f1, f2, and nf to compute the response. % % </TestDescription> function result = utp_13 % <SyntaxDescription> % % Call the method with different method to pass f1, f2, and nf in. % % </SyntaxDescription> try % <SyntaxCode> f1 = .1; f2 = 5; nf = 123; out1 = resp(fir5, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'lin')); out2 = resp(fir5, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'log')); out3 = resp(fir5, plist('scale', 'lin')); out4 = resp(fir5, plist('scale', 'log')); mout1 = rebuild(out1); mout2 = rebuild(out2); mout3 = rebuild(out3); mout4 = rebuild(out4); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; T = 10e-12; if stest % <AlgoCode> % Check the output nfd = find(mfir.getInfo('resp', 'Range').plists, 'nf'); f1d = fir5.fs/1000; f2d = fir5.fs/2-1/nfd; if ~isa(out1, 'ao'), atest = false; end if ~isa(out2, 'ao'), atest = false; end if ~isa(out3, 'ao'), atest = false; end if ~isa(out4, 'ao'), atest = false; end xlin1 = linspace(f1, f2, nf); xlin2 = linspace(f1d, f2d, nfd); xlog1 = logspace(log10(f1), log10(f2), nf); xlog2 = logspace(log10(f1d), log10(f2d), nfd); if ~isequal(xlin1, out1.x'), atest = false; end if ~isequal(xlin2, out3.x'), atest = false; end if ~isequal(xlog1, out2.x'), atest = false; end if ~isequal(xlog2, out4.x'), atest = false; end % Check the rebuilding of the object if ~eq(out1, mout1, ple2), atest = false; end if ~eq(out2, mout2, ple2), atest = false; end if ~eq(out3, mout3, ple2), atest = false; end if ~eq(out4, mout4, ple2), atest = false; end % </AlgoCode> else atest = false; end % Return a result structure result = utp_prepare_result(atest, stest, dbstack, mfilename); end % END UTP_13 %% UTP_14 % <TestDescription> % % Check that the resp method the response of a serial filter bank. % % </TestDescription> function result = utp_14 % <SyntaxDescription> % % Check that the resp method the response of a serial filter bank. % % </SyntaxDescription> try % <SyntaxCode> out = resp(fir1, fir2, plist('bank', 'serial')); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; if stest % <AlgoCode> % Check the output if ~isa(out, 'ao'), atest = false; end if numel(out) ~= 1, atest = false; end s1 = resp(fir1); s2 = resp(fir2); stot = s1 .* s2; if ~isequal(stot.x, out.x), atest = false; end if ~isequal(stot.y, out.y), atest = false; end % Check the rebuilding of the object if ~eq(out, mout, ple2), 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> % % Check that the resp method the response of a parallel filter bank. % % </TestDescription> function result = utp_15 % <SyntaxDescription> % % Check that the resp method the response of a parallel filter bank. % % </SyntaxDescription> try % <SyntaxCode> out = resp(fir1, fir2, plist('bank', 'parallel')); mout = rebuild(out); % </SyntaxCode> stest = true; catch err disp(err.message) stest = false; end % <AlgoDescription> % % 1) Check the output % 2) Check that the 'rebuild' method produces the same object as 'out'. % % </AlgoDescription> atest = true; T = 10e-12; if stest % <AlgoCode> % Check the output if ~isa(out, 'ao'), atest = false; end if numel(out) ~= 1, atest = false; end s1 = resp(fir1); s2 = resp(fir2); stot = s1 + s2; if ~isequal(stot.x, out.x), atest = false; end if ~isequal(stot.y, out.y), atest = false; end % Check the rebuilding of the object if ~eq(out, mout, 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 end