function [A,B,C,D,E,dx0,x0,u0,y0,Delays] = fixInputDF(sys,indices,values,varargin)
% The indexing operation SYS(I,J) sets discarded inputs to zero. 
% Use fixInput for all other interpretations.

%   Copyright 2022-2023 The MathWorks, Inc.
[A,B,C,D,E,dx0,x0,u0,y0,Delays] = sys.DataFunction(varargin{:});
[~,nu] = iosize(sys);
nfd = nfdelay(sys);

% Absorb u-u0 contribution of discarded inputs
% Note: Contribution is zero where input is set to 'u0'.
ndel = numel(indices);
ufix = zeros(ndel,1);
jnum = find(cellfun(@(x) isnumeric(x),values));
if isempty(u0)
   ufix(jnum,:) = cat(1,values{jnum});
else
   ufix(jnum,:) = cat(1,values{jnum})-u0(indices(jnum),:);
end
if isempty(dx0)
   dx0 = B(:,indices)*ufix;
else
   dx0 = dx0+B(:,indices)*ufix;
end
if isempty(y0)
   y0 = D(:,indices)*ufix;
else
   y0 = y0+D(:,indices)*ufix;
end

% Update delays
if ~isempty(Delays)
   Delays.Input(indices,:) = [];
end

% Delete discarded inputs
colIndex = 1:nu+nfd;  colIndex(:,indices) = [];
B = B(:,colIndex);
D = D(:,colIndex);
if ~isempty(u0)
   u0 = u0(colIndex,:);
end
