function [ret,x0,str,ts,xts]=einf_bei(t,x,u,flag);
%EINF_BEI *** is the M-file description of the SIMULINK system named EINF_BEI.
%	The block-diagram can be displayed by typing: EINF_BEI.
%
%	SYS=EINF_BEI(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 EINF_BEI 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 EINF_BEI with a FLAG of zero:
%	[SIZES]=EINF_BEI([],[],[],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',     '17')
set_param(sys,'Min step size', '0.00000001')
set_param(sys,'Max step size', '0.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Filter',[sys,'/','Filter'])
set_param([sys,'/','Filter'],...
		'Numerator','[VF]',...
		'Denominator','[1 f1 f2]',...
		'Sample time','T',...
		'position',[100,11,160,49])

add_block('built-in/Filter',[sys,'/','Regler'])
set_param([sys,'/','Regler'],...
		'Numerator','[VR VRd1 VRd2]',...
		'Denominator','[1 -1]',...
		'Sample time','T',...
		'position',[270,11,330,49])

add_block('built-in/Step Fcn',[sys,'/','Step Input'])
set_param([sys,'/','Step Input'],...
		'position',[45,20,65,40])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'inputs','+-',...
		'position',[185,24,205,51])

add_block('built-in/Zero-Order Hold',[sys,'/',['Zero-Order',13,'Hold']])
set_param([sys,'/',['Zero-Order',13,'Hold']],...
		'orientation',2,...
		'Sample time','T',...
		'position',[225,59,260,91])


%     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','17\/-0.1\/1.2\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Graph'.

set_param([sys,'/','Graph'],...
		'position',[450,151,480,189])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','3',...
		'position',[390,154,420,186])

add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn2'])
set_param([sys,'/','Transfer Fcn2'],...
		'Denominator','[1 1]',...
		'position',[130,157,165,193])

add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn3'])
set_param([sys,'/','Transfer Fcn3'],...
		'Denominator','[2 1]',...
		'position',[205,157,240,193])

add_block('built-in/To File',[sys,'/','To File'])
set_param([sys,'/','To File'],...
		'File name','bu_pimk.mat',...
		'Matrix name','bu_pimk',...
		'position',[340,280,415,310])

add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
		'mat-name','yout',...
		'position',[420,97,470,113])

add_block('built-in/Step Fcn',[sys,'/','Step Input1'])
set_param([sys,'/','Step Input1'],...
		'After','0',...
		'position',[345,40,365,60])

add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
		'inputs','+-',...
		'position',[385,20,405,40])

add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn'])
set_param([sys,'/','Transfer Fcn'],...
		'Denominator','[1 1]',...
		'position',[445,12,480,48])

add_block('built-in/Transfer Fcn',[sys,'/','Transfer Fcn1'])
set_param([sys,'/','Transfer Fcn1'],...
		'Denominator','[2 1]',...
		'position',[515,12,550,48])
add_line(sys,[370,50;380,35])
add_line(sys,[485,30;510,30])
add_line(sys,[70,30;95,30])
add_line(sys,[165,30;180,30])
add_line(sys,[220,75;170,75;180,45])
add_line(sys,[210,40;230,40;230,30;265,30])
add_line(sys,[425,170;445,170])
add_line(sys,[170,175;200,175])
add_line(sys,[80,30;80,175;125,175])
add_line(sys,[245,175;310,175;310,170;385,170])
add_line(sys,[335,30;350,30;350,25;380,25])
add_line(sys,[410,30;440,30])
add_line(sys,[555,30;565,30;565,75;265,75])
add_line(sys,[405,75;415,105])
add_line(sys,[385,75;385,85;360,85;360,160;385,160])
add_line(sys,[335,75;335,85;320,85;320,295;335,295])

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
