function dummy = openloop(LoopData)
%OPENLOOP  Computes normalized open-loop ZPK model.

%   Author(s): P. Gahinet
%   Copyright 1986-2000 The MathWorks, Inc. 
%   $Revision: 1.2 $  $Date: 2000/06/14 20:18:28 $

% NORMOPENLOOP = normalized open-loop model (for compensator's GainMag set to 1)

% REVISIT
dummy = [];

CompData = LoopData.Compensator;

% Current compensator gain data
% REVISIT: merge next statements into one
Gain = CompData.Gain; GainMag = Gain.Magnitude;

% Get ZPK data for normalized compensator
% RE: GainMag=1 is relative to the current format and may translate into a
% non-unity gain in the ZPK format
% REVISIT: merge next statements into one
ZPData = getpz(CompData);  Zc = ZPData{1};  Pc = ZPData{2};
% REVISIT: merge next statements into one
Gain.Magnitude = 1; CompData.Gain = Gain;
NormGain = convertgain(CompData,CompData.Format,'ZeroPoleGain');
Gain.Magnitude = GainMag; CompData.Gain = Gain;

% Construct open-loop ZPK data
Zero = [LoopData.Plant.Zero ; LoopData.Sensor.Zero ; Zc];
Pole = [LoopData.Plant.Pole ; LoopData.Sensor.Pole ; Pc]; 
Gain = (-LoopData.FeedbackSign) * LoopData.Plant.Gain * ...
    LoopData.Sensor.Gain * NormGain.Sign * NormGain.Magnitude;

% Set property value
if Gain
    LoopData.OpenLoop = zpk(Zero,Pole,Gain,CompData.Ts);
else
    LoopData.OpenLoop = zpk([],[],0,CompData.Ts);  % no locus if loop gain is zero
end

