function [yf,y0] = getFinalValue(D,RespType,Config,DC)
% Computes initial and final (steady-state) output value for a given 
% response type, assuming stability. CONFIG contains the response 
% configuration and DC (optional) contains the DC gain.

%   Copyright 2020-2023 The MathWorks, Inc.
[ny,nu] = iosize(D);
switch RespType
   case {'step','impulse'}
      if nargin<4
         DC = dcgain(D);
      end
      if any(Config.InputOffset)
         OutputOffset = DC * Config.InputOffset;
      else
         OutputOffset = zeros(ny,1);
      end
      if strcmp(RespType,'step')
         yf = OutputOffset + DC .* Config.Amplitude';
      else
         % REVISIT: Assumes impulses have zero DC contribution. Can we do better?
         yf = OutputOffset + zeros(ny,nu);
      end
      if isempty(Config.InitialState)
         % Start from steady state
         y0 = repmat(OutputOffset,[1 nu]);
      else
         % Initial state specified (likely unsteady)
         [~,~,y0] = resolveIC(D,Config.InitialState,Config.InputOffset);
      end

   case 'initial'
      y0 = zeros(ny,1);
      yf = zeros(ny,1);
end
