function StepRespObj = pvset(StepRespObj,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.14 $   $Date: 2000/06/14 20:05:40 $

ni = nargin;
ContextMenu = get(StepRespObj.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
         StepRespObj.PeakResponse = Value;
         set(ContextMenu.PlotOptions.PeakResponse,'Checked',Value);
         StepRespObj = respfcn('showpeak',StepRespObj);
      end
      
   case 'RiseTime',
      if ~any(strcmpi(Value,{'on';'off'})),
         error(sprintf('Bad value for response property: %s.',Property))
      else
         StepRespObj.RiseTime = Value;
         set(ContextMenu.PlotOptions.RiseTime,'Checked',Value);
         StepRespObj = respfcn('showrise',StepRespObj);
      end
      
   case 'RiseTimeLimits',
      StepRespObj.RiseTimeLimits = Value;
      RiseTimeValue = calcopt('risetimevalue',StepRespObj);
      StepRespObj.RiseTimeValue = RiseTimeValue;
      if strcmp(get(ContextMenu.PlotOptions.RiseTime,'Checked'),'on'); % replot
         StepRespObj = respfcn('replotopt',StepRespObj,'RiseTimeMarker','LocalPlotRiseTime');
      end
      
   case 'SettlingTime',
      if ~any(strcmpi(Value,{'on';'off'})),
         error(sprintf('Bad value for response property: %s.',Property))
      else
         StepRespObj.SettlingTime= Value;
         set(ContextMenu.PlotOptions.SettlingTime,'Checked',Value);
         StepRespObj = respfcn('showsettling',StepRespObj);
      end
      
   case 'SettlingTimeThreshold',
      StepRespObj.SettlingTimeThreshold= Value;
      SettlingTimeValue = calcopt('settlingtimevalue',StepRespObj);
      StepRespObj.SettlingTimeValue = SettlingTimeValue;
      if strcmp(get(ContextMenu.PlotOptions.SettlingTime,'Checked'),'on'); % replot
         StepRespObj = respfcn('replotopt',StepRespObj,'SettlingTimeMarker','LocalPlotSetTime');
      end
      
   case 'SteadyState'
      if ~any(strcmpi(Value,{'on';'off'})),
         error(sprintf('Bad value for response property: %s.',Property))
      else
         StepRespObj.SteadyState= Value;
         set(ContextMenu.PlotOptions.SteadyState,'Checked',Value);
         StepRespObj = respfcn('showsteady',StepRespObj);
      end
      
   case  {'RiseTimeValue','PeakResponseValue','SteadyStateValue','SettlingTimeValue'},
      error(sprintf('Attempt to modify read-only property %s',Property))
      
   otherwise
      RespObjProp([i i+1]) = logical(1);
      
   end % switch Property
end % for i

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


