function Value = pvget(RespObj,Property)
%PVGET  Get values of public Response Object properties.
%
%   VALUES = PVGET(RespObj) returns the values of all public 
%   properties of RespObj in the cell array VALUES.
%
%   VALUES = PVGET(RespObj,PROPERTY) returns the value of the
%   single property with name PROPERTY.  The string property
%   must contain the true property name.
%   
%   See also GET.

%   Authors: P. Gahinet, 7-8-97
%   Revised: A. DiVergilio
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.8 $  $Date: 2000/06/14 20:09:12 $

ni = nargin;

% Get all NYPLOT-specific public properties and their values
NyqPropNames = pnames(RespObj,'specific');
NyqPropValues = struct2cell(RespObj);

% Get property value(s)
if ni==1
   % Get all property values
   Value = [NyqPropValues(1:length(NyqPropNames)) ; ...
         pvget(RespObj.response)];
else
   % Value of single property
   % Look among NYPLOT-specific properties
   imatch = find(strcmp(Property,NyqPropNames));

   if isempty(imatch)
      % Look among parent properties
      Value = pvget(RespObj.response,Property);

   elseif any(strcmp(Property,{'PeakResponseValue','StabilityMarginValue','AllStabilityMarginValue'}))
      % Special NYPLOT-specific property
      Value = builtin('subsref',RespObj,substruct('.',Property));
      if any(cellfun('isempty',{Value.System}))
         % Compute Peak Response
         [Value,RespObj] = calcopt(Property,RespObj);
         ContextMenu = pvget(RespObj.response,'UIContextMenu');
         builtin('set',ContextMenu.Main,'UserData',RespObj)
      end

   else
      % Other NYPLOT-specific property
      Value = NyqPropValues{imatch};
   end
end
