function [ret,x0,str,ts,xts]=sdcmot(t,x,u,flag);
%SDCMOT	is the M-file description of the SIMULINK system named SDCMOT.
%	The block-diagram can be displayed by typing: SDCMOT.
%
%	SYS=SDCMOT(T,X,U,FLAG) returns depending on FLAG certain
%	system values given time point, T, current state vector, X,
%	and input vector, U.
%	FLAG is used to indicate the type of output to be returned in SYS.
%
%	Setting FLAG=1 causes SDCMOT to return state derivatives, FLAG=2
%	discrete states, FLAG=3 system outputs and FLAG=4 next sample
%	time. For more information and other options see SFUNC.
%
%	Calling SDCMOT with a FLAG of zero:
%	[SIZES]=SDCMOT([],[],[],0),  returns a vector, SIZES, which
%	contains the sizes of the state vector and other parameters.
%		SIZES(1) number of states
%		SIZES(2) number of discrete states
%		SIZES(3) number of outputs
%		SIZES(4) number of inputs
%		SIZES(5) number of roots (currently unsupported)
%		SIZES(6) direct feedthrough flag
%		SIZES(7) number of sample times
%
%	For the definition of other parameters in SIZES, see SFUNC.
%	See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.

% Note: This M-file is only used for saving graphical information;
%       after the model is loaded into memory an internal model
%       representation is used.

% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(1.3)
if (0 == (nargin + nargout))
     set_param(sys,'Location',[27,137,527,437])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-23')
set_param(sys,'Start time',    '0')
set_param(sys,'Stop time',     '5')
set_param(sys,'Min step size', '0.01')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/S-Function',[sys,'/','S-Function'])
set_param([sys,'/','S-Function'],...
		'BackGround',5,...
		'function name','dcmotor',...
		'position',[205,92,275,128])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'hide name',0,...
		'inputs','3',...
		'position',[145,94,175,126])

add_block('built-in/Note',[sys,'/','Separately Excited DC Motor'])
set_param([sys,'/','Separately Excited DC Motor'],...
		'Font Name','helvetica',...
		'Font Weight','bold',...
		'Font Angle','oblique',...
		'Font Size',18,...
		'position',[205,10,210,15])

add_block('built-in/Demux',[sys,'/','Demux'])
set_param([sys,'/','Demux'],...
		'outputs','3',...
		'position',[305,94,345,126])


%     Subsystem  'Field Current'.

new_system([sys,'/','Field Current'])
set_param([sys,'/','Field Current'],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['Field Current/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Field Current/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt',...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/','Field Current/x'])
set_param([sys,'/','Field Current/x'],...
		'position',[65,55,85,75])
add_line([sys,'/','Field Current'],[90,65;125,65])
set_param([sys,'/','Field Current'],...
		'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
		'Mask Type','Storage scope.')
set_param([sys,'/','Field Current'],...
		'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):')
set_param([sys,'/','Field Current'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Field Current'],...
		'Mask Help','This block uses a MATLAB figure window to plot the input signal.  The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer.  Line type must be in quotes.  See the M-file sfunyst.m.')
set_param([sys,'/','Field Current'],...
		'Mask Entries','5\/0\/1\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Field Current'.

set_param([sys,'/','Field Current'],...
		'BackGround',3,...
		'position',[410,80,440,120])


%     Subsystem  'Rotor Speed'.

new_system([sys,'/','Rotor Speed'])
set_param([sys,'/','Rotor Speed'],'Location',[0,59,274,252])

add_block('built-in/Inport',[sys,'/','Rotor Speed/x'])
set_param([sys,'/','Rotor Speed/x'],...
		'position',[65,55,85,75])

add_block('built-in/S-Function',[sys,'/',['Rotor Speed/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Rotor Speed/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt',...
		'position',[130,55,180,75])
add_line([sys,'/','Rotor Speed'],[90,65;125,65])
set_param([sys,'/','Rotor Speed'],...
		'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
		'Mask Type','Storage scope.')
set_param([sys,'/','Rotor Speed'],...
		'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):')
set_param([sys,'/','Rotor Speed'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Rotor Speed'],...
		'Mask Help','This block uses a MATLAB figure window to plot the input signal.  The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer.  Line type must be in quotes.  See the M-file sfunyst.m.')
set_param([sys,'/','Rotor Speed'],...
		'Mask Entries','5\/0\/10\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Rotor Speed'.

set_param([sys,'/','Rotor Speed'],...
		'orientation',2,...
		'BackGround',3,...
		'position',[220,155,250,195])


%     Subsystem  'Armature Current'.

new_system([sys,'/','Armature Current'])
set_param([sys,'/','Armature Current'],'Location',[0,59,274,252])

add_block('built-in/S-Function',[sys,'/',['Armature Current/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Armature Current/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts, dt',...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/','Armature Current/x'])
set_param([sys,'/','Armature Current/x'],...
		'position',[65,55,85,75])
add_line([sys,'/','Armature Current'],[90,65;125,65])
set_param([sys,'/','Armature Current'],...
		'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
		'Mask Type','Storage scope.')
set_param([sys,'/','Armature Current'],...
		'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):')
set_param([sys,'/','Armature Current'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Armature Current'],...
		'Mask Help','This block uses a MATLAB figure window to plot the input signal.  The graph limits are automatically scaled to the min and max values of the signal stored in the scope''s signal buffer.  Line type must be in quotes.  See the M-file sfunyst.m.')
set_param([sys,'/','Armature Current'],...
		'Mask Entries','5\/-5\/10\/2000\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Armature Current'.

set_param([sys,'/','Armature Current'],...
		'BackGround',3,...
		'position',[410,155,440,195])

add_block('built-in/Step Fcn',[sys,'/','Load Torque'])
set_param([sys,'/','Load Torque'],...
		'BackGround',6,...
		'Time','2',...
		'After','10',...
		'position',[75,150,95,170])

add_block('built-in/Step Fcn',[sys,'/','Vf'])
set_param([sys,'/','Vf'],...
		'BackGround',7,...
		'Time','0',...
		'After','240',...
		'position',[25,90,45,110])

add_block('built-in/Step Fcn',[sys,'/','Va'])
set_param([sys,'/','Va'],...
		'BackGround',7,...
		'Time','.5',...
		'After','10',...
		'position',[55,110,75,130])


%     Subsystem  ['Double click here',13,'to start loading data',13,'and mu-syn design1'].

new_system([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],'Location',[2,439,106,512])
set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'Mask Display','Load\nData',...
		'Mask Dialogue','eval([''dcm_par''])')


%     Finished composite block ['Double click here',13,'to start loading data',13,'and mu-syn design1'].

set_param([sys,'/',['Double click here',13,'to start loading data',13,'and mu-syn design1']],...
		'ForeGround',1,...
		'BackGround',2,...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[33,219,84,246])
add_line(sys,[180,110;200,110])
add_line(sys,[280,110;300,110])
add_line(sys,[50,100;140,100])
add_line(sys,[80,120;90,120;90,110;140,110])
add_line(sys,[100,160;100,120;140,120])
add_line(sys,[350,100;405,100])
add_line(sys,[350,110;375,110;375,175;405,175])
add_line(sys,[350,120;360,120;360,175;255,175])

drawnow

% Return any arguments.
if (nargin | nargout)
	% Must use feval here to access system in memory
	if (nargin > 3)
		if (flag == 0)
			eval(['[ret,x0,str,ts,xts]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str,ts,xts] = feval(sys);
	end
else
	drawnow % Flash up the model and execute load callback
end
