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

add_block('built-in/Note',[sys,'/','System output-----> '])
set_param([sys,'/','System output-----> '],...
		'position',[60,210,65,215])

add_block('built-in/Note',[sys,'/','System input------>'])
set_param([sys,'/','System input------>'],...
		'position',[55,190,60,195])

add_block('built-in/Note',[sys,'/','System output----->'])
set_param([sys,'/','System output----->'],...
		'position',[65,95,70,100])

add_block('built-in/Note',[sys,'/','System noise------>'])
set_param([sys,'/','System noise------>'],...
		'position',[55,230,60,235])

add_block('built-in/Note',[sys,'/','System noise-----> '])
set_param([sys,'/','System noise-----> '],...
		'position',[70,120,75,125])


%     Subsystem  ['Double click',13,'on this block',13,'for a demo.'].

new_system([sys,'/',['Double click',13,'on this block',13,'for a demo.']])
set_param([sys,'/',['Double click',13,'on this block',13,'for a demo.']],'Location',[-10,380,117,533])
set_param([sys,'/',['Double click',13,'on this block',13,'for a demo.']],...
		'Mask Display','DEMO',...
		'Mask Dialogue','eval(''simident'')')


%     Finished composite block ['Double click',13,'on this block',13,'for a demo.'].

set_param([sys,'/',['Double click',13,'on this block',13,'for a demo.']],...
		'position',[224,216,279,250])


%     Subsystem  ['General model',13,'estimator using',13,'Predictive Error Method'].

new_system([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/input noise']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/input noise']],...
		'Port','3',...
		'position',[55,140,75,160])

add_block('built-in/Mux',[sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/Mux']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/Mux']],...
		'inputs','3',...
		'position',[130,82,160,118])

add_block('built-in/Inport',[sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/system output']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/system output']],...
		'Port','2',...
		'position',[55,90,75,110])

add_block('built-in/S-Function',[sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/S-function',13,'block ']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[205,80,260,120])

add_block('built-in/Inport',[sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/system input']])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method/system input']],...
		'position',[55,40,75,60])
add_line([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],[165,100;200,100])
add_line([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],[80,100;125,100])
add_line([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],[80,50;110,50;110,90;125,90])
add_line([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],[80,150;110,150;110,110;125,110])
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Mask Display','PEM',...
		'Mask Type','PEM')
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Mask Dialogue','General model estimator.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Orders of model [na nb nc nd nf nk]:|Calculate after how many points:|Sample time:')
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Mask Translate','method = ''pem''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. The input noise, which is  optional, may be hooked to input 3.\nResults are displayed as the estimated output versus the true output in graphical form. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Mask Entries','256\/[3 3 3 3 3 0]\/64\/0.05\/')


%     Finished composite block ['General model',13,'estimator using',13,'Predictive Error Method'].

set_param([sys,'/',['General model',13,'estimator using',13,'Predictive Error Method']],...
		'Drop Shadow',4,...
		'position',[335,297,380,353])


%     Subsystem  ['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator'].

new_system([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_3']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_3']],...
		'Port','3',...
		'position',[55,135,75,155])

add_block('built-in/Mux',[sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/Mux']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/Mux']],...
		'inputs','3',...
		'position',[100,77,130,113])

add_block('built-in/Inport',[sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_2']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_2']],...
		'Port','2',...
		'position',[55,85,75,105])

add_block('built-in/S-Function',[sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/S-function',13,'block ']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[200,75,255,115])

add_block('built-in/Inport',[sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_1']])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator/in_1']],...
		'position',[55,35,75,55])
add_line([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],[80,145;95,105])
add_line([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],[135,95;195,95])
add_line([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],[80,45;95,85])
add_line([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],[80,95;95,95])
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Mask Display','ARMAX',...
		'Mask Type','ARMAX')
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Mask Dialogue','ARMAX model estimator.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Orders of model [na nb nc nk]|Calculate after how many points:|Sample time:')
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Mask Translate','method = ''armax''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. The input noise, which is  optional, may be hooked to input 3.\nResults are displayed as the estimated output versus the true output in graphical form. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Mask Entries','256\/[3 3 3 0]\/64\/0.05\/')


%     Finished composite block ['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator'].

set_param([sys,'/',['AutoRegressive Moving',13,'Average with eXternal',13,'input model estimator']],...
		'Drop Shadow',4,...
		'position',[330,93,385,147])


%     Subsystem  ['Box-Jenkins',13,'model estimator'].

new_system([sys,'/',['Box-Jenkins',13,'model estimator']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['Box-Jenkins',13,'model estimator/input noise']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator/input noise']],...
		'Port','3',...
		'position',[55,140,75,160])

add_block('built-in/Mux',[sys,'/',['Box-Jenkins',13,'model estimator/Mux']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator/Mux']],...
		'inputs','3',...
		'position',[130,82,160,118])

add_block('built-in/Inport',[sys,'/',['Box-Jenkins',13,'model estimator/system output']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator/system output']],...
		'Port','2',...
		'position',[55,90,75,110])

add_block('built-in/S-Function',[sys,'/',['Box-Jenkins',13,'model estimator/S-function',13,'block ']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator/S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[205,80,260,120])

add_block('built-in/Inport',[sys,'/',['Box-Jenkins',13,'model estimator/system input']])
set_param([sys,'/',['Box-Jenkins',13,'model estimator/system input']],...
		'position',[55,40,75,60])
add_line([sys,'/',['Box-Jenkins',13,'model estimator']],[165,100;200,100])
add_line([sys,'/',['Box-Jenkins',13,'model estimator']],[80,100;125,100])
add_line([sys,'/',['Box-Jenkins',13,'model estimator']],[80,50;110,50;110,90;125,90])
add_line([sys,'/',['Box-Jenkins',13,'model estimator']],[80,150;110,150;110,110;125,110])
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Mask Display','BJ',...
		'Mask Type','BJ')
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Mask Dialogue','Box-Jenkins model estimator.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Orders of model [na nc nd nf nk]|Calculate after how many points:|Sample time:')
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Mask Translate','method = ''bj''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. The input noise, which is   optional, may be hooked to input 3.\nResults are displayed as the estimated output versus the true output in graphical form. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Mask Entries','256\/[3 3 3 3 0]\/64\/0.05\/')


%     Finished composite block ['Box-Jenkins',13,'model estimator'].

set_param([sys,'/',['Box-Jenkins',13,'model estimator']],...
		'Drop Shadow',4,...
		'position',[335,197,380,253])

add_block('built-in/Note',[sys,'/',['System Identification Toolbox',13,'model estimators. For more information ',13,'unmask these blocks and look at the ',13,'S-function: sfunid.m.',13,'See also the corresponding toolbox ',13,'help entries.']])
set_param([sys,'/',['System Identification Toolbox',13,'model estimators. For more information ',13,'unmask these blocks and look at the ',13,'S-function: sfunid.m.',13,'See also the corresponding toolbox ',13,'help entries.']],...
		'position',[245,5,250,10])


%     Subsystem  ['AutoRegressive',13,'model estimator'].

new_system([sys,'/',['AutoRegressive',13,'model estimator']])
set_param([sys,'/',['AutoRegressive',13,'model estimator']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['AutoRegressive',13,'model estimator/input noise']])
set_param([sys,'/',['AutoRegressive',13,'model estimator/input noise']],...
		'Port','2',...
		'position',[60,120,80,140])

add_block('built-in/Mux',[sys,'/',['AutoRegressive',13,'model estimator/Mux']])
set_param([sys,'/',['AutoRegressive',13,'model estimator/Mux']],...
		'inputs','3',...
		'position',[140,57,170,123])

add_block('built-in/Inport',[sys,'/',['AutoRegressive',13,'model estimator/system output']])
set_param([sys,'/',['AutoRegressive',13,'model estimator/system output']],...
		'position',[55,80,75,100])

add_block('built-in/S-Function',[sys,'/',['AutoRegressive',13,'model estimator/S-function',13,'block ']])
set_param([sys,'/',['AutoRegressive',13,'model estimator/S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[205,70,260,110])
add_line([sys,'/',['AutoRegressive',13,'model estimator']],[80,90;135,90])
add_line([sys,'/',['AutoRegressive',13,'model estimator']],[175,90;200,90])
add_line([sys,'/',['AutoRegressive',13,'model estimator']],[85,130;115,130;115,110;135,110])
set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Mask Display','AR',...
		'Mask Type','AR')
set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Mask Dialogue','Autoregressive model estimator.\nHook input 1 to system input.\nHook input 2 to the system''s noise input.|Length of buffer:|Orders of model [na]:|Calculate after how many points:|Sample time:')
set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Mask Translate','method = ''ar''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Mask Help','Hook the system''s output to the first port of this block and the system noise to the second port.\nResults are displayed as the estimated output versus the true output in graphical form.')
set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Mask Entries','256\/3\/64\/0.05\/')


%     Finished composite block ['AutoRegressive',13,'model estimator'].

set_param([sys,'/',['AutoRegressive',13,'model estimator']],...
		'Drop Shadow',4,...
		'position',[130,90,180,145])


%     Subsystem  ['AutoRegressive ',13,'with eXternal input',13,'model estimator'].

new_system([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/system input']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/system input']],...
		'position',[55,40,75,60])

add_block('built-in/S-Function',[sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/S-function',13,'block ']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[205,80,260,120])

add_block('built-in/Inport',[sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/system output']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/system output']],...
		'Port','2',...
		'position',[55,90,75,110])

add_block('built-in/Mux',[sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/Mux']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/Mux']],...
		'inputs','3',...
		'position',[130,82,160,118])

add_block('built-in/Inport',[sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/input noise']])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator/input noise']],...
		'Port','3',...
		'position',[55,140,75,160])
add_line([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],[80,150;110,150;110,110;125,110])
add_line([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],[80,50;110,50;110,90;125,90])
add_line([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],[80,100;125,100])
add_line([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],[165,100;200,100])
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Mask Display','ARX',...
		'Mask Type','ARX')
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Mask Dialogue','ARX model estimator.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Orders of model [na nb nk]:|Calculate after how many points:|Sample time:')
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Mask Translate','method = ''arx''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. The input noise, which is  optional, may be hooked to input 3.\nResults are displayed as the estimated output versus the true output in graphical form. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Mask Entries','256\/[3 4 0]\/64\/0.05\/')


%     Finished composite block ['AutoRegressive ',13,'with eXternal input',13,'model estimator'].

set_param([sys,'/',['AutoRegressive ',13,'with eXternal input',13,'model estimator']],...
		'Drop Shadow',4,...
		'position',[130,192,175,248])


%     Subsystem  ['Output-error ',13,'model estimator.'].

new_system([sys,'/',['Output-error ',13,'model estimator.']])
set_param([sys,'/',['Output-error ',13,'model estimator.']],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/',['Output-error ',13,'model estimator./system input']])
set_param([sys,'/',['Output-error ',13,'model estimator./system input']],...
		'position',[55,40,75,60])

add_block('built-in/S-Function',[sys,'/',['Output-error ',13,'model estimator./S-function',13,'block ']])
set_param([sys,'/',['Output-error ',13,'model estimator./S-function',13,'block ']],...
		'function name','sfunid',...
		'parameters','order,npts,HowOften,offset,ts,method',...
		'position',[205,80,260,120])

add_block('built-in/Inport',[sys,'/',['Output-error ',13,'model estimator./system output']])
set_param([sys,'/',['Output-error ',13,'model estimator./system output']],...
		'Port','2',...
		'position',[55,90,75,110])

add_block('built-in/Mux',[sys,'/',['Output-error ',13,'model estimator./Mux']])
set_param([sys,'/',['Output-error ',13,'model estimator./Mux']],...
		'inputs','3',...
		'position',[130,82,160,118])

add_block('built-in/Inport',[sys,'/',['Output-error ',13,'model estimator./input noise']])
set_param([sys,'/',['Output-error ',13,'model estimator./input noise']],...
		'Port','3',...
		'position',[55,140,75,160])
add_line([sys,'/',['Output-error ',13,'model estimator.']],[80,150;110,150;110,110;125,110])
add_line([sys,'/',['Output-error ',13,'model estimator.']],[80,50;110,50;110,90;125,90])
add_line([sys,'/',['Output-error ',13,'model estimator.']],[80,100;125,100])
add_line([sys,'/',['Output-error ',13,'model estimator.']],[165,100;200,100])
set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Mask Display','OE',...
		'Mask Type','OE')
set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Mask Dialogue','Output-error model estimator.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Orders of model [nb nf nk]:|Calculate after how many points:|Sample time:')
set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Mask Translate','method = ''oe''; npts=@1; order=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. The input noise, which is  optional, may be hooked to input 3.\nResults are displayed as the estimated output versus the true output in graphical form. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Mask Entries','256\/[3 3 0]\/64\/0.05\/')


%     Finished composite block ['Output-error ',13,'model estimator.'].

set_param([sys,'/',['Output-error ',13,'model estimator.']],...
		'Drop Shadow',4,...
		'position',[130,302,175,358])

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
