function [ret,x0,str,ts,xts]=br_si_jo(t,x,u,flag);
%BR_SI_JO	is the M-file description of the SIMULINK system named BR_SI_JO.
%	The block-diagram can be displayed by typing: BR_SI_JO.
%
%	SYS=BR_SI_JO(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 BR_SI_JO 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 BR_SI_JO with a FLAG of zero:
%	[SIZES]=BR_SI_JO([],[],[],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',[0,38,624,464])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '250')
set_param(sys,'Min step size', '0.000001')
set_param(sys,'Max step size', '1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Gain',[sys,'/','TM'])
set_param([sys,'/','TM'],...
		'Gain','1/TM',...
		'position',[125,282,150,308])

add_block('built-in/Gain',[sys,'/','TF'])
set_param([sys,'/','TF'],...
		'Gain','1/TF',...
		'position',[305,282,330,308])

add_block('built-in/Integrator',[sys,'/','Feder'])
set_param([sys,'/','Feder'],...
		'position',[365,285,385,305])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'inputs','+-',...
		'position',[70,285,90,305])

add_block('built-in/Integrator',[sys,'/','Motor'])
set_param([sys,'/','Motor'],...
		'position',[180,285,200,305])

add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
		'inputs','+-',...
		'position',[245,285,265,305])

add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
		'inputs','+-',...
		'position',[230,110,250,130])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','3',...
		'position',[445,29,475,61])


%     Subsystem  'Graph'.

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

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

add_block('built-in/S-Function',[sys,'/',['Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfuny',...
		'parameters','ax, color,dt',...
		'position',[130,55,180,75])
add_line([sys,'/','Graph'],[90,65;125,65])
set_param([sys,'/','Graph'],...
		'Mask Display','plot(0,0,100,100,[90,10,10,10,90,90,10],[65,65,90,40,40,90,90],[90,78,69,54,40,31,25,10],[77,60,48,46,56,75,81,84])',...
		'Mask Type','Graph scope.')
set_param([sys,'/','Graph'],...
		'Mask Dialogue','Graph scope using MATLAB graph window.\nEnter plotting ranges and line type.|Time range:|y-min:|y-max:|Line type (rgbw-:*). Seperate each plot by ''/'':')
set_param([sys,'/','Graph'],...
		'Mask Translate','color = @4; ax = [0, @1, @2, @3]; dt = -1;')
set_param([sys,'/','Graph'],...
		'Mask Help','This block plots to the MATLAB graph window and can be used as an improved version of the Scope block. Look at the m-file sfuny.m to see how it works. This block can take scalar or vector input signal.')
set_param([sys,'/','Graph'],...
		'Mask Entries','251\/-0.1\/1.1\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Graph'.

set_param([sys,'/','Graph'],...
		'position',[510,26,540,64])

add_block('built-in/To File',[sys,'/','To File'])
set_param([sys,'/','To File'],...
		'File name','br_si_x.mat',...
		'Matrix name','br_si_x',...
		'position',[495,85,570,115])

add_block('built-in/Sum',[sys,'/','Sum5'])
set_param([sys,'/','Sum5'],...
		'orientation',2,...
		'position',[115,165,135,185])

add_block('built-in/Gain',[sys,'/','Federmoment'])
set_param([sys,'/','Federmoment'],...
		'orientation',2,...
		'Gain','K2',...
		'position',[210,157,235,183])

add_block('built-in/Gain',[sys,'/','n-motor'])
set_param([sys,'/','n-motor'],...
		'Gain','K3',...
		'position',[180,102,205,128])

add_block('built-in/Zero-Order Hold',[sys,'/','Halteglied'])
set_param([sys,'/','Halteglied'],...
		'Sample time','T',...
		'position',[125,99,160,131])

add_block('built-in/Sum',[sys,'/','Sum4'])
set_param([sys,'/','Sum4'],...
		'inputs','+-',...
		'position',[80,105,100,125])

add_block('built-in/Step Fcn',[sys,'/','Sollwert'])
set_param([sys,'/','Sollwert'],...
		'Time','T',...
		'position',[30,75,50,95])

add_block('built-in/Transfer Fcn',[sys,'/','Gg-Str'])
set_param([sys,'/','Gg-Str'],...
		'Denominator','[Tel 1]',...
		'position',[295,102,330,138])

add_block('built-in/Zero-Order Hold',[sys,'/','Halteglied1'])
set_param([sys,'/','Halteglied1'],...
		'orientation',2,...
		'Sample time','T',...
		'position',[295,154,330,186])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'inputs','-+',...
		'position',[470,280,490,300])

add_block('built-in/Gain',[sys,'/','TL'])
set_param([sys,'/','TL'],...
		'Gain','1/TL',...
		'position',[510,277,535,303])

add_block('built-in/Integrator',[sys,'/',' Last'])
set_param([sys,'/',' Last'],...
		'position',[560,280,580,300])

add_block('built-in/Zero-Order Hold',[sys,'/','Halteglied2'])
set_param([sys,'/','Halteglied2'],...
		'orientation',2,...
		'Sample time','T',...
		'position',[295,199,330,231])

add_block('built-in/Gain',[sys,'/','delta n'])
set_param([sys,'/','delta n'],...
		'orientation',2,...
		'Gain','K1',...
		'position',[210,202,235,228])

add_block('built-in/Constant',[sys,'/','Lastmoment'])
set_param([sys,'/','Lastmoment'],...
		'orientation',2,...
		'Value','0',...
		'position',[550,240,570,260])
add_line(sys,[55,85;60,85;60,110;75,110])
add_line(sys,[205,215;180,215;180,180;140,180])
add_line(sys,[545,250;445,250;445,285;465,285])
add_line(sys,[95,295;120,295])
add_line(sys,[155,295;175,295])
add_line(sys,[270,295;300,295])
add_line(sys,[335,295;360,295])
add_line(sys,[495,290;505,290])
add_line(sys,[540,290;555,290])
add_line(sys,[205,295;215,295;215,290;240,290])
add_line(sys,[585,290;595,290;595,320;225,320;225,300;240,300])
add_line(sys,[390,295;465,295])
add_line(sys,[400,295;400,355;40,355;40,300;65,300])
add_line(sys,[215,290;215,265;55,265;55,120;75,120])
add_line(sys,[110,175;100,175;100,155;215,155;225,125])
add_line(sys,[205,170;140,170])
add_line(sys,[480,45;505,45])
add_line(sys,[335,120;345,120;345,15;15,15;15,290;65,290])
add_line(sys,[480,45;490,100])
add_line(sys,[255,120;290,120])
add_line(sys,[210,115;225,115])
add_line(sys,[165,115;175,115])
add_line(sys,[105,115;120,115])
add_line(sys,[290,170;240,170])
add_line(sys,[400,295;400,170;335,170])
add_line(sys,[290,215;240,215])
add_line(sys,[280,295;280,275;365,275;365,215;335,215])
add_line(sys,[365,215;365,35;440,35])
add_line(sys,[595,290;595,140;425,140;425,55;440,55])
add_line(sys,[215,265;385,265;385,45;440,45])

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
