function dcmsimu(odesuite);
% DCMSIMU
%         Matlab function to simulate a separately excited DC motor 
%         with dynamic equations described given in the function
%         DCM_ODE.M  .  This routine works well with both Matlab 4.x
%         amd Matlab 5.x
%
% SINTAX: Under Matlab 4.2 with ODESUITE or Matlab 5.x
%           dcmsimu(1)
%         Under Matlab 4.x or Matlab 5.x 
%           dcmsimu
%
% CALLS:  DCM_PAR.M (parameter file) and DCM_ODE.M (ode file)
%
% Copyright JCCK Feb, March 1999
 
global Rf Ra Laa Lff Laf Bm Jm Xo Vf
 
% Set if ODESUITE is present (default is not present)
  if nargin==0, odesuite=0;end;

% Initialize Parameters
  dcm_par;
 
% Simulation Parameters
 % Time Scale
  to = 0;
  tf = 5;
 % Initial Conditions
  Xo=[0;0;0];
 % Field Voltage
  Vf=240;
 
% Simulate: ODE solver ode45
  if odesuite,	% ODESUITE is present
    [t,sys]=ode45('dcm_ode',[to,tf],Xo);
  else  	% Default	
    [t,sys]=ode45('dcm_ode',to,tf,Xo);
  end;   
 
% Show results
  figure(1)
  plot(t,sys);
  title('Separately Excited DC Motor');
  xlabel('Time [sec]')
  ylabel('States');
  legend('If','Ia','Wr');
