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

add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
		'inputs','9',...
		'position',[260,142,315,268])

add_block('built-in/Memory',[sys,'/','Memory1'])
set_param([sys,'/','Memory1'],...
		'position',[635,120,675,150])

add_block('built-in/Memory',[sys,'/','Memory'])
set_param([sys,'/','Memory'],...
		'position',[525,120,565,150])

add_block('built-in/Memory',[sys,'/','Memory2'])
set_param([sys,'/','Memory2'],...
		'position',[615,190,655,220])

add_block('built-in/Memory',[sys,'/','Memory3'])
set_param([sys,'/','Memory3'],...
		'position',[700,190,740,220])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','6',...
		'position',[825,131,855,164])

add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn'])
set_param([sys,'/','MATLAB Fcn'],...
		'orientation',2,...
		'MATLAB Fcn','ident',...
		'Output Width','5',...
		'position',[695,303,755,337])


%     Subsystem  'Saída'.

new_system([sys,'/','Saída'])
set_param([sys,'/','Saída'],'Location',[0,59,274,252])

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

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


%     Finished composite block 'Saída'.

set_param([sys,'/','Saída'],...
		'position',[870,221,900,259])

add_block('built-in/Discrete Transfer Fcn',[sys,'/',['Discrete',13,'Transfer Fcn']])
set_param([sys,'/',['Discrete',13,'Transfer Fcn']],...
		'Numerator','[.8 -.7]',...
		'Denominator','[1 .5 .5]',...
		'position',[500,179,580,231])


%     Subsystem  'Erro'.

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

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

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


%     Finished composite block 'Erro'.

set_param([sys,'/','Erro'],...
		'orientation',2,...
		'position',[430,366,460,404])

add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn1'])
set_param([sys,'/','MATLAB Fcn1'],...
		'MATLAB Fcn','contid',...
		'Output Width','1',...
		'position',[335,188,395,222])

add_block('built-in/Memory',[sys,'/','Memory4'])
set_param([sys,'/','Memory4'],...
		'position',[420,190,460,220])


%     Subsystem  ['Sinal de Controle',13,''].

new_system([sys,'/',['Sinal de Controle',13,'']])
set_param([sys,'/',['Sinal de Controle',13,'']],'Location',[0,59,274,252])

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

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


%     Finished composite block ['Sinal de Controle',13,''].

set_param([sys,'/',['Sinal de Controle',13,'']],...
		'position',[465,26,495,64])

add_block('built-in/Demux',[sys,'/','Demux'])
set_param([sys,'/','Demux'],...
		'orientation',2,...
		'outputs','5',...
		'position',[620,291,680,349])

add_block('built-in/Signal Generator',[sys,'/',['Signal',13,'Generator']])
set_param([sys,'/',['Signal',13,'Generator']],...
		'Peak','1.000000',...
		'Peak Range','5000.000000',...
		'Freq','0.170000',...
		'Freq Range','5.000000',...
		'Wave','Sin',...
		'Units','Rads',...
		'position',[65,128,110,162])
add_line(sys,[570,135;630,135])
add_line(sys,[585,205;610,205])
add_line(sys,[660,205;695,205])
add_line(sys,[680,135;820,135])
add_line(sys,[610,135;610,165;685,165;685,140;820,140])
add_line(sys,[745,205;745,150;820,150])
add_line(sys,[670,205;670,235;770,235;770,155;820,155])
add_line(sys,[585,205;585,245;790,245;790,160;820,160])
add_line(sys,[860,150;930,150;930,320;760,320])
add_line(sys,[690,320;685,320])
add_line(sys,[615,340;615,385;465,385])
add_line(sys,[790,240;865,240])
add_line(sys,[320,205;330,205])
add_line(sys,[615,300;570,300;570,285;245,285;255,160])
add_line(sys,[615,310;525,310;525,295;235,295;235,175;255,175])
add_line(sys,[615,320;565,320;565,395;530,395;530,355;225,355;225,190;255,190])
add_line(sys,[615,330;570,330;570,445;535,445;535,420;215,420;215,205;255,205])
add_line(sys,[595,135;595,110;190,110;190,235;255,235])
add_line(sys,[795,240;795,485;205,485;205,250;255,250])
add_line(sys,[675,235;675,275;810,275;810,500;195,500;195,265;255,265])
add_line(sys,[115,145;255,145])
add_line(sys,[400,205;415,205])
add_line(sys,[465,205;495,205])
add_line(sys,[475,205;475,135;520,135])
add_line(sys,[475,150;415,150;415,130;200,130;200,220;255,220])
add_line(sys,[475,175;705,175;705,145;820,145])
add_line(sys,[400,205;400,45;460,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
