view testing/utp_1.1/utps/rational/utp_rational_resp.m @ 49:0bcdf74587d1 database-connection-manager

Cleanup
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:36 +0100
parents 409a22968d5e
children
line wrap: on
line source

% UTP_RATIONAL_RESP a set of UTPs for the rational/resp method
%
% M Hewitson 06-08-08
%
% $Id: utp_rational_resp.m,v 1.7 2010/03/15 15:57:06 ingo Exp $
%

% <MethodDescription>
%
% The resp method of the rational class returns the complex response of a
% rational TF as an Analysis Object. For a command with no output variables
% plots the method the result into a diagram.
%
% </MethodDescription>

function results = utp_rational_resp(varargin)

  % Check the inputs
  if nargin == 0

    % Some keywords
    class   = 'rational';
    mthd    = 'resp';

    results = [];
    disp('******************************************************');
    disp(['****  Running UTPs for ' class '/' mthd]);
    disp('******************************************************');

    % Test RATIONAL objects
    [ra1,ra2,ra3,rav,ram] = get_test_objects_rational;

    % Exception list for the UTPs:
    [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();

    warning('This UTP needs a complete update');
    
    % 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'

    % 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 RATIONAL objects as
  % input.
  %
  % </TestDescription>
  function result = utp_02

    % <SyntaxDescription>
    %
    % Test that the resp method works for a vector of RATIONAL 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(rav);
      out = resp(rav);
      % </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 'rav'
    % 3) Check that each output RATIONAL contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-13;
    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(rav), atest = false; end
      % Check the number of output objects.
      if ~isequal(size(out), size(rav)), atest = false; end
      % Check each output against the default values for f1, f2 and nf
      for ii = 1:numel(out)
        f1 = getlowerFreq(rav(ii))/10;
        f2 = getupperFreq(rav(ii))*10;
        nf = 1000;
        if ~isa(out(ii), 'ao'), atest = false; end
        if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
        if abs(out(ii).x(1)   - f1) > TOL, atest = false; end
        if abs(out(ii).x(end) - f2) > TOL, atest = false; end
        if numel(out(ii).x) ~= nf, atest = false; end
        s = 2*pi*1i*out(ii).x;
        numr = polyval(rav(ii).num, s);
        denr = polyval(rav(ii).den, s);
        rsp = numr./denr;
        if ~isequal(out(ii).y, rsp), 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 RATIONAL objects as
  % input.
  %
  % </TestDescription>
  function result = utp_03

    % <SyntaxDescription>
    %
    % Tests that the resp method works with a matrix of RATIONAL 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(ram);
      out = resp(ram);
      % </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 'ram'
    % 3) Check that each output RATIONAL contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-13;
    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(ram), atest = false; end
      % Check the number of output objects.
      if ~isequal(size(out), size(ram)), atest = false; end
      % Check each output against the default values for f1, f2 and nf
      for ii = 1:numel(out)
        f1 = getlowerFreq(ram(ii))/10;
        f2 = getupperFreq(ram(ii))*10;
        nf = 1000;
        if ~isa(out(ii), 'ao'), atest = false; end
        if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
        if abs(out(ii).x(1)   - f1) > TOL, atest = false; end
        if abs(out(ii).x(end) - f2) > TOL, atest = false; end
        if numel(out(ii).x) ~= nf, atest = false; end
        s = 2*pi*1i*out(ii).x;
        numr = polyval(ram(ii).num, s);
        denr = polyval(ram(ii).den, s);
        rsp = numr./denr;
        if ~isequal(out(ii).y, rsp), 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 RATIONAL objects as
  % input.
  %
  % </TestDescription>
  function result = utp_04

    % <SyntaxDescription>
    %
    % Tests that the resp method works with a list of RATIONAL 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(ra1, ra2, ra3);
      out = resp(ra1, ra2, ra3);
      % </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 'rain'
    % 3) Check that each output RATIONAL contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-13;
    rain  = [ra1, ra2, ra3];
    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(rain), atest = false; end
      % Check the number of output objects.
      if ~isequal(size(out), size(rain)), atest = false; end
      % Check each output against the default values for f1, f2 and nf
      for ii = 1:numel(out)
        f1 = getlowerFreq(rain(ii))/10;
        f2 = getupperFreq(rain(ii))*10;
        nf = 1000;
        if ~isa(out(ii), 'ao'), atest = false; end
        if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
        if abs(out(ii).x(1)   - f1) > TOL, atest = false; end
        if abs(out(ii).x(end) - f2) > TOL, atest = false; end
        if numel(out(ii).x) ~= nf, atest = false; end
        s = 2*pi*1i*out(ii).x;
        numr = polyval(rain(ii).num, s);
        denr = polyval(rain(ii).den, s);
        rsp = numr./denr;
        if ~isequal(out(ii).y, rsp), 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
  % RATIONAL objects as input.
  %
  % </TestDescription>
  function result = utp_05

    % <SyntaxDescription>
    %
    % Tests that the resp method works with a mix of different shaped
    % RATIONAL 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(ra1, ram, rav);
      out = resp(ra1, ram, rav);
      % </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 'rain'
    % 3) Check that each output RATIONAL contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-13;
    rain  = [ra1, reshape(ram, 1, []), reshape(rav, 1, [])];
    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(rain), atest = false; end
      % Check the number of output objects.
      if ~isequal(size(out), size(rain)), atest = false; end
      % Check each output against the default values for f1, f2 and nf
      for ii = 1:numel(out)
        f1 = getlowerFreq(rain(ii))/10;
        f2 = getupperFreq(rain(ii))*10;
        nf = 1000;
        if ~isa(out(ii), 'ao'), atest = false; end
        if ~strcmp(out(ii).hist.methodInfo.mname, 'resp'), atest = false; end
        if abs(out(ii).x(1)   - f1) > TOL, atest = false; end
        if abs(out(ii).x(end) - f2) > TOL, atest = false; end
        if numel(out(ii).x) ~= nf, atest = false; end
        s = 2*pi*1i*out(ii).x;
        numr = polyval(rain(ii).num, s);
        denr = polyval(rain(ii).den, s);
        rsp = numr./denr;
        if ~isequal(out(ii).y, rsp), 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(ra1);
      out  = resp(ra1);
      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;
      ra1.resp();
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check the response diagram.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-13;
    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');
      f1 = getlowerFreq(ra1)/10;
      f2 = getupperFreq(ra1)*10;
      nf = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
      if abs(x(1)   - f1) > TOL, atest = false; end
      if abs(x(end) - f2) > TOL, 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>
      arow = ao(1:123, linspace(.1, 5, 123));
      acol = arow.';
      f    = linspace(.1, 5, 123);
      out1 = resp(ra2, arow);
      out2 = resp(ra2, acol);
      out3 = resp(ra2, 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(ra1, ra1);
      o3  = resp(ra1, ra1);
      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 = 123;
      axy = ao(linspace(f1, f2, nf), randn(nf,1));
      afs = ao(linspace(f1, f2, nf), randn(nf,1), plist('type', 'fsdata'));
      out1 = resp(ra3, axy);
      out2 = resp(ra3, afs);
      out3 = resp(ra3, plist('f', axy));
      out4 = resp(ra3, plist('f', afs));

      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;
    if stest
      % <AlgoCode>
      % Check the output
      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
      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
      if out3.x(1)     ~= f1, atest = false; end
      if out3.x(end)   ~= f2, atest = false; end
      if numel(out3.x) ~= nf, atest = false; end
      if out4.x(1)     ~= f1, atest = false; end
      if out4.x(end)   ~= f2, atest = false; end
      if numel(out4.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
      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_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(ra3, f);
      out2 = resp(ra3, plist('f', f));

      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_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;
      out1 = resp(ra3, f1, f2);
      out2 = resp(ra3, f1, f2, nf);
      out3 = resp(ra3, plist('f1', f1, 'f2', f2, 'nf', nf));
      out4 = resp(ra3, plist('f1', f1, 'nf', nf2));
      out5 = resp(ra3, plist('f2', f2));

      mout1 = rebuild(out1);
      mout2 = rebuild(out2);
      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 = 10e-12;
    if stest
      % <AlgoCode>
      % Check the output
      f1d = getlowerFreq(ra3)/10;
      f2d = getupperFreq(ra3)*10;
      nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
      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
      if ~isa(out5, 'ao'), atest = false; end
      if out1.x(1)     ~= f1, atest = false; end
      if abs(out1.x(end)-f2)>T, atest = false; end
      if numel(out1.x) ~= nfd, atest = false; end % Default values
      if out2.x(1)     ~= f1, atest = false; end
      if abs(out2.x(end)-f2)>T, atest = false; end
      if numel(out2.x) ~= nf, 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) - f2d) > 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(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
      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(ra3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'lin'));
      out2 = resp(ra3, plist('f1', f1, 'f2', f2, 'nf', nf, 'scale', 'log'));
      out3 = resp(ra3, plist('scale', 'lin'));
      out4 = resp(ra3, 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
      f1d = getlowerFreq(ra3)/10;
      f2d = getupperFreq(ra3)*10;
      nfd = find(pzmodel.getInfo('resp', 'Range').plists, 'nf');
      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

end