function ImpRespObj = pvset(ImpRespObj,varargin)
%PVSET  Set properties of Response Objects.
%
%   RespObj = PVSET(RespObj,'Property1',Value1,'Property2',Value2,...)
%   sets the values of the properties with exact names 'Property1',
%   'Property2',...
%
%   See also SET.

%   Author(s): A. Potvin, 3-1-94
%   Revised: P. Gahinet, 4-1-96
%   Revised for Response Objects: K. Gondoly, 1-5-98
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.13 $  $Date: 2000/06/14 20:10:51 $

ni = nargin;
ContextMenu = get(ImpRespObj.response,'UicontextMenu');
RespObjProp = logical(zeros(ni-1,1));

for i=1:2:ni-1,
   % Set each Property Name/Value pair in turn. 
   Property = varargin{i};
   Value = varargin{i+1};
   if ischar(Value),
      Value = lower(Value);
   end
   
   switch Property
   case 'PeakResponse',
      if ~any(strcmpi(Value,{'on';'off'})),
         error(sprintf('Bad value for response property %s.',Property))
      else
         ImpRespObj.PeakResponse = Value;
         set(ContextMenu.PlotOptions.PeakResponse,'Checked',Value);
         ImpRespObj = respfcn('showpeak',ImpRespObj);
      end
      
   case 'SettlingTime',
      if ~any(strcmpi(Value,{'on';'off'})),
         error(sprintf('Bad value for response property %s.',Property))
      else
         ImpRespObj.SettlingTime= Value;
         set(ContextMenu.PlotOptions.SettlingTime,'Checked',Value);
         ImpRespObj = respfcn('showsettling',ImpRespObj);
      end
      
   case 'SettlingTimeThreshold',
      ImpRespObj.SettlingTimeThreshold= Value;
      SettlingTimeValue = calcopt('settlingtimevalue',ImpRespObj);
      ImpRespObj.SettlingTimeValue = SettlingTimeValue;
      if strcmp(get(ContextMenu.PlotOptions.SettlingTime,'Checked'),'on'); % replot
         ImpRespObj = respfcn('replotopt',ImpRespObj,'SettlingTimeMarker','LocalPlotSetTime');
      end
      
   case  {'PeakResponseValue','SettlingTimeValue'},
      error(sprintf('Attempt to modify read-only property %s',Property))
      
   otherwise
      % PROPERTY is a parent @response property. 
      RespObjProp([i i+1]) = logical(1);
      
   end % switch Property
end

% Set all @response properties
RespObjProp = find(RespObjProp);
if ~isempty(RespObjProp)
   ImpRespObj.response = pvset(ImpRespObj.response,varargin{RespObjProp});
end

