function schema
%SCHEMA  Defines properties for @nicholsgain margin class

%   Author(s): Bora Eryilmaz
%   Revised:
%   Copyright 1986-2002 The MathWorks, Inc. 
%   $Revision: 1.1.6.2 $ $Date: 2004/12/10 19:31:33 $

pk = findpackage('plotconstr');

% Register class 
c = schema.class(pk, 'nicholsgain', findclass(pk, 'designconstr'));

% Editor data
p = schema.prop(c, 'MagnitudeUnits', 'string'); % Magnitude units
p.FactoryValue = 'dB';
p.SetFunction = {@localSet 'MagnitudeUnits'};      % Map frequency to x-axis
p.GetFunction = {@localGet 'MagnitudeUnits'};

p = schema.prop(c, 'MarginGain', 'mxArray');     % Gain margin (in dB)
p.SetFunction = {@localSet 'MarginGain'};      % Map frequency to x-axis
p.GetFunction = {@localGet 'MarginGain'};

p = schema.prop(c, 'OriginPha',  'mxArray');     % Phase origin (in deg)
p.SetFunction = {@localSet 'OriginPha'};      % Map frequency to x-axis
p.GetFunction = {@localGet 'OriginPha'};

p = schema.prop(c, 'PhaseUnits', 'string');  % Phase units
p.FactoryValue = 'deg';
p.SetFunction = {@localSet 'PhaseUnits'};      % Map frequency to x-axis
p.GetFunction = {@localGet 'PhaseUnits'};

%--------------------------------------------------------------------------
function valueStored = localSet(this, Value, fld)

fld = localFieldMapping(fld);

this.setData(fld,Value);
if ischar(Value)
   valueStored = '';
else
   valueStored = [];
end

%--------------------------------------------------------------------------
function valueReturned = localGet(this, Value, fld)

fld = localFieldMapping(fld);
valueReturned = this.getData(fld);

%--------------------------------------------------------------------------
function fld = localFieldMapping(fld)

switch lower(fld)
   case 'originpha'
      fld = 'xCoords';
   case 'phaseunits'
      fld = 'xUnits';
   case 'margingain'
      fld = 'yCoords';
   case 'magnitudeunits'
      fld = 'yUnits';
end