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

add_block('built-in/Sum',[sys,'/','Sum4'])
set_param([sys,'/','Sum4'],...
		'hide name',0,...
		'inputs','+-',...
		'position',[130,239,150,281])

add_block('built-in/Sum',[sys,'/','Sum1'])
set_param([sys,'/','Sum1'],...
		'hide name',0,...
		'position',[330,229,350,271])

add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
		'orientation',2,...
		'hide name',0,...
		'position',[380,345,400,385])

add_block('built-in/Transfer Fcn',[sys,'/','Sistema'])
set_param([sys,'/','Sistema'],...
		'Denominator','[1 1]',...
		'position',[395,230,450,270])

add_block('built-in/Step Fcn',[sys,'/','d2'])
set_param([sys,'/','d2'],...
		'Time','3',...
		'position',[395,155,435,185])

add_block('built-in/Sum',[sys,'/','Sum2'])
set_param([sys,'/','Sum2'],...
		'hide name',0,...
		'position',[540,219,560,261])

add_block('built-in/Gain',[sys,'/','Gain1'])
set_param([sys,'/','Gain1'],...
		'hide name',0,...
		'position',[460,157,485,183])

add_block('built-in/Step Fcn',[sys,'/','d1'])
set_param([sys,'/','d1'],...
		'Time','2',...
		'position',[200,155,240,185])

add_block('built-in/Gain',[sys,'/','Gain2'])
set_param([sys,'/','Gain2'],...
		'hide name',0,...
		'position',[265,157,290,183])

add_block('built-in/Gain',[sys,'/','Gain3'])
set_param([sys,'/','Gain3'],...
		'orientation',2,...
		'hide name',0,...
		'Gain','0',...
		'position',[520,380,550,410])

add_block('built-in/Step Fcn',[sys,'/','d3'])
set_param([sys,'/','d3'],...
		'orientation',2,...
		'Time','4',...
		'position',[600,380,640,410])

add_block('built-in/Step Fcn',[sys,'/','rif'])
set_param([sys,'/','rif'],...
		'position',[10,235,50,265])

add_block('built-in/Gain',[sys,'/','Gain4'])
set_param([sys,'/','Gain4'],...
		'hide name',0,...
		'position',[75,237,100,263])


%     Subsystem  'Errore'.

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

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

add_block('built-in/S-Function',[sys,'/',['Errore/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Errore/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,'/','Errore'],[90,65;125,65])
set_param([sys,'/','Errore'],...
		'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,'/','Errore'],...
		'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,'/','Errore'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Errore'],...
		'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,'/','Errore'],...
		'Mask Entries','1\/-1\/1\/20000\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Errore'.

set_param([sys,'/','Errore'],...
		'position',[205,70,235,110])


%     Subsystem  'Uscita'.

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

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

add_block('built-in/S-Function',[sys,'/',['Uscita/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Uscita/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,'/','Uscita'],[90,65;125,65])
set_param([sys,'/','Uscita'],...
		'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,'/','Uscita'],...
		'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,'/','Uscita'],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=-1;')
set_param([sys,'/','Uscita'],...
		'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,'/','Uscita'],...
		'Mask Entries','1\/-1\/1\/20000\/''y-/g--/c-./w:/m*/ro/b+''\/')


%     Finished composite block 'Uscita'.

set_param([sys,'/','Uscita'],...
		'position',[640,220,670,260])

add_block('built-in/Gain',[sys,'/','1//Kd'])
set_param([sys,'/','1//Kd'],...
		'orientation',2,...
		'position',[205,349,250,381])

add_block('built-in/Gain',[sys,'/','Guadagno'])
set_param([sys,'/','Guadagno'],...
		'Gain','10',...
		'Mask Display','10',...
		'Mask Dialogue','eval(''slideg(1,10,200,0)'');',...
		'position',[225,246,275,274])

add_block('built-in/Note',[sys,'/',['Esercitazione di Fondamenti di Automatica',13,'']])
set_param([sys,'/',['Esercitazione di Fondamenti di Automatica',13,'']],...
		'position',[465,20,470,25])

add_block('built-in/Note',[sys,'/',['Schema di controllo con sistema di tipo 0:',13,'']])
set_param([sys,'/',['Schema di controllo con sistema di tipo 0:',13,'']],...
		'position',[245,465,250,470])

add_block('built-in/Note',[sys,'/','# comportamento al variare del guadagno rispetto al riferimento e ai disturbi benefici'])
set_param([sys,'/','# comportamento al variare del guadagno rispetto al riferimento e ai disturbi benefici'],...
		'position',[320,490,325,495])

add_block('built-in/Note',[sys,'/','#  Kd'])
set_param([sys,'/','#  Kd'],...
		'position',[45,520,50,525])

add_block('built-in/Note',[sys,'/','# importante disturbo sulla misura d3'])
set_param([sys,'/','# importante disturbo sulla misura d3'],...
		'position',[155,550,160,555])

add_block('built-in/Note',[sys,'/',['abilitare o disabilitare i vari disturbi ponendo ',13,'il guadagno pari a 1 o 0 in uscita ai vari generatori di segnale']])
set_param([sys,'/',['abilitare o disabilitare i vari disturbi ponendo ',13,'il guadagno pari a 1 o 0 in uscita ai vari generatori di segnale']],...
		'position',[480,50,485,55])
add_line(sys,[155,260;220,260])
add_line(sys,[455,250;535,250])
add_line(sys,[355,250;390,250])
add_line(sys,[440,170;455,170])
add_line(sys,[245,170;260,170])
add_line(sys,[595,395;555,395])
add_line(sys,[565,240;635,240])
add_line(sys,[515,395;480,395;480,375;405,375])
add_line(sys,[55,250;70,250])
add_line(sys,[105,250;125,250])
add_line(sys,[565,240;575,240;575,355;405,355])
add_line(sys,[295,170;310,170;310,240;325,240])
add_line(sys,[490,170;515,170;515,230;535,230])
add_line(sys,[180,260;180,90;200,90])
add_line(sys,[375,365;255,365])
add_line(sys,[200,365;105,365;105,270;125,270])
add_line(sys,[280,260;325,260])

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
