function u=dcm_inp(t,x);

% DCM_INP
%       Matlab function to generate external inputs and disturbances 
%       acting on a separately excited dcmotor with dynamic equations
%       given in dcm_ode.m
%
%       This file is invoqued by DCM_ODE.M
%
% SYNTAX: u=dcm_inp(t,x);
%
% ARGINS	t = time vector
%		x = state vector
% ARGOUTS	u = vector of inputs

% Copyright JCCK, Feb 1999
 
% External inputs: u = (Vf,Va,Tl)
%    	Vf - Field winding voltage
%    	Va - Armature winding voltage
%    	Tl - Load torque disturbance

% Initialize
  u=[];

% Repeat for each element of t

  for tt=t,	% tt is temporaty variable

  % Generate external signals
    % 1.1 Field Voltage: Constant
          Vf=240;
  
    % 1.2 Armature Voltage: Step at .5 sec
      if tt<.5,  
         Va = 0;
      else 
        Va=10;
      end;
    
    % 1.3 Load Disturbance: Step at 2 sec
      if tt<2,
        Tl = 0;	
      else 
        Tl=10;
      end;

    % Stack data
      u=[u; Vf Va Tl];

  end; % for tt

return
