function [ret,x0,str,ts,xts]=extrdisp(t,x,u,flag);
%EXTRDISP	is the M-file description of the SIMULINK system named EXTRDISP.
%	The block-diagram can be displayed by typing: EXTRDISP.
%
%	SYS=EXTRDISP(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 EXTRDISP 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 EXTRDISP with a FLAG of zero:
%	[SIZES]=EXTRDISP([],[],[],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',[33,129,366,502])
     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',   '')


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

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


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

set_param([sys,'/',['Double click',13,'on this for demo.3']],...
		'hide name',0,...
		'position',[137,260,191,291])


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

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


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

set_param([sys,'/',['Double click',13,'on this for demo.2']],...
		'hide name',0,...
		'position',[140,167,191,196])


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

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


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

set_param([sys,'/',['Double click',13,'on this for demo.1']],...
		'hide name',0,...
		'position',[139,73,188,106])


%     Subsystem  'Average PSD'.

new_system([sys,'/','Average PSD'])
set_param([sys,'/','Average PSD'],'Location',[0,0,285,136])

add_block('built-in/S-Function',[sys,'/',['Average PSD/S-function block ',13,'which calls M-file']])
set_param([sys,'/',['Average PSD/S-function block ',13,'which calls M-file']],...
		'function name','sfunpsd',...
		'parameters','fftpts,npts,HowOften,offset,ts,1',...
		'position',[175,46,225,84])

add_block('built-in/Inport',[sys,'/','Average PSD/input signal'])
set_param([sys,'/','Average PSD/input signal'],...
		'position',[65,55,85,75])
add_line([sys,'/','Average PSD'],[90,65;170,65])
set_param([sys,'/','Average PSD'],...
		'Mask Display','plot(0,0,100,100,[11,92,92,11,11],[90,90,40,40,90],[82,76,65,57,51,44,35,30,25,20],[65,62,59,63,66,66,67,70,55,50])',...
		'Mask Type','Spectrum analyzer.')
set_param([sys,'/','Average PSD'],...
		'Mask Dialogue','Spectrum analyzer using graph window.|Length of buffer:|Number of points for fft:|Plot after how many points:|Sample time:')
set_param([sys,'/','Average PSD'],...
		'Mask Translate','npts=@1; fftpts=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/','Average PSD'],...
		'Mask Help','This block when hooked to the output of a system displays the frequency content of the buffer in the graph window. For more see the M-file sfunpsd.',...
		'Mask Entries','128\/512\/64\/0.1\/')


%     Finished composite block 'Average PSD'.

set_param([sys,'/','Average PSD'],...
		'Drop Shadow',4,...
		'position',[240,72,270,108])


%     Subsystem  'Spectrum Analyzer'.

new_system([sys,'/','Spectrum Analyzer'])
set_param([sys,'/','Spectrum Analyzer'],'Location',[0,0,371,185])

add_block('built-in/Inport',[sys,'/','Spectrum Analyzer/system input'])
set_param([sys,'/','Spectrum Analyzer/system input'],...
		'position',[55,30,75,50])

add_block('built-in/S-Function',[sys,'/',['Spectrum Analyzer/S-function block',13,'which calls M-file']])
set_param([sys,'/',['Spectrum Analyzer/S-function block',13,'which calls M-file']],...
		'function name','sfuntf',...
		'parameters','fftpts,npts,HowOften,offset,ts,0',...
		'position',[250,72,295,108])

add_block('built-in/Inport',[sys,'/','Spectrum Analyzer/system output'])
set_param([sys,'/','Spectrum Analyzer/system output'],...
		'Port','2',...
		'position',[55,110,75,130])

add_block('built-in/Mux',[sys,'/','Spectrum Analyzer/Mux'])
set_param([sys,'/','Spectrum Analyzer/Mux'],...
		'inputs','2',...
		'position',[145,71,175,104])
add_line([sys,'/','Spectrum Analyzer'],[180,90;245,90])
add_line([sys,'/','Spectrum Analyzer'],[80,40;110,40;110,80;140,80])
add_line([sys,'/','Spectrum Analyzer'],[80,120;110,120;110,95;140,95])
set_param([sys,'/','Spectrum Analyzer'],...
		'Mask Display','plot(0,0,100,100,[11,93,93,11,11],[90,90,40,40,90],[90,80,72,64,55,45,41,36,20],[50,50,52,59,67,75,78,80,80])',...
		'Mask Type','Spectrum analyzer.')
set_param([sys,'/','Spectrum Analyzer'],...
		'Mask Dialogue','Spectrum analyser using graph window.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Number of points for fft:|Plot after how many points:|Sample time:')
set_param([sys,'/','Spectrum Analyzer'],...
		'Mask Translate','npts=@1; fftpts=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/','Spectrum Analyzer'],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. Results are displayed as the frequency response of this system. Use signals with high harmonic content for best results. ')
set_param([sys,'/','Spectrum Analyzer'],...
		'Mask Entries','256\/256\/64\/0.1\/')


%     Finished composite block 'Spectrum Analyzer'.

set_param([sys,'/','Spectrum Analyzer'],...
		'Drop Shadow',4,...
		'position',[55,160,85,200])


%     Subsystem  ['Power Spectral',13,'Sensity'].

new_system([sys,'/',['Power Spectral',13,'Sensity']])
set_param([sys,'/',['Power Spectral',13,'Sensity']],'Location',[0,0,276,140])

add_block('built-in/Inport',[sys,'/',['Power Spectral',13,'Sensity/input signal']])
set_param([sys,'/',['Power Spectral',13,'Sensity/input signal']],...
		'position',[50,55,70,75])

add_block('built-in/S-Function',[sys,'/',['Power Spectral',13,'Sensity/S-function block ',13,'which calls M-file']])
set_param([sys,'/',['Power Spectral',13,'Sensity/S-function block ',13,'which calls M-file']],...
		'function name','sfunpsd',...
		'parameters','fftpts,npts,HowOften,offset,ts,0',...
		'position',[160,46,210,84])
add_line([sys,'/',['Power Spectral',13,'Sensity']],[75,65;155,65])
set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Mask Display','plot(0,0,100,100,[14,91,91,14,14],[86,86,40,40,86],[85,82,80,79,75,67,63,60,57,53,41,36,33,27,24],[49,50,53,50,49,51,54,66,54,50,50,52,81,51,49])')
set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Mask Type','Spectrum analyzer.',...
		'Mask Dialogue','Spectrum analyser using graph window.|Length of buffer:|Number of points for fft:|Plot after how many points:|Sample time:')
set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Mask Translate','npts=@1; fftpts=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Mask Help','This block when hooked to the output of a system displays the frequency content of the buffer in the graph window. For more see the M-file specanal.')
set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Mask Entries','128\/512\/64\/0.1\/')


%     Finished composite block ['Power Spectral',13,'Sensity'].

set_param([sys,'/',['Power Spectral',13,'Sensity']],...
		'Drop Shadow',4,...
		'position',[55,65,85,105])


%     Subsystem  'Cross Correlator'.

new_system([sys,'/','Cross Correlator'])
set_param([sys,'/','Cross Correlator'],'Location',[0,0,385,199])

add_block('built-in/Inport',[sys,'/','Cross Correlator/signal 1'])
set_param([sys,'/','Cross Correlator/signal 1'],...
		'position',[50,55,70,75])

add_block('built-in/Inport',[sys,'/','Cross Correlator/signal 2'])
set_param([sys,'/','Cross Correlator/signal 2'],...
		'Port','2',...
		'position',[50,105,70,125])

add_block('built-in/Mux',[sys,'/','Cross Correlator/Mux'])
set_param([sys,'/','Cross Correlator/Mux'],...
		'inputs','2',...
		'position',[150,81,180,114])

add_block('built-in/S-Function',[sys,'/',['Cross Correlator/S-function block',13,'which calls M-file']])
set_param([sys,'/',['Cross Correlator/S-function block',13,'which calls M-file']],...
		'function name','sfuncorr',...
		'parameters','npts,HowOften,offset,ts,1,''unbiased''',...
		'position',[225,83,290,117])
add_line([sys,'/','Cross Correlator'],[75,65;100,65;100,90;145,90])
add_line([sys,'/','Cross Correlator'],[75,115;100,115;100,105;145,105])
add_line([sys,'/','Cross Correlator'],[185,100;220,100])
set_param([sys,'/','Cross Correlator'],...
		'Mask Display','plot(0,0,100,100,[10,92,92,10,10],[90,90,40,40,90],[80,59,40,20],[70,79,70,79],[79,70,59,51,40,30,21],[60,51,60,50,60,50,60])',...
		'Mask Type','Crosscorrelator.')
set_param([sys,'/','Cross Correlator'],...
		'Mask Dialogue','Cross correlator using graph window.\nRequires signal processing toolbox.|Length of buffer:|Plot after how many points:|Sample time:')
set_param([sys,'/','Cross Correlator'],...
		'Mask Translate','npts=@1; HowOften=@2; ts=@3(1); if length(@3) > 1, offset = @3(2), else, offset = 0; end')
set_param([sys,'/','Cross Correlator'],...
		'Mask Help','This block when hooked to the outputs of a system displays the cross correlation of the buffer in the graph window. For more see the M-file crosscor.',...
		'Mask Entries','100\/50\/0.1\/')


%     Finished composite block 'Cross Correlator'.

set_param([sys,'/','Cross Correlator'],...
		'Drop Shadow',4,...
		'position',[55,254,85,296])


%     Subsystem  'Auto Correlator'.

new_system([sys,'/','Auto Correlator'])
set_param([sys,'/','Auto Correlator'],'Location',[0,0,274,124])

add_block('built-in/Inport',[sys,'/','Auto Correlator/input signal'])
set_param([sys,'/','Auto Correlator/input signal'],...
		'position',[50,55,70,75])

add_block('built-in/S-Function',[sys,'/',['Auto Correlator/S-function block',13,'which calls M-file']])
set_param([sys,'/',['Auto Correlator/S-function block',13,'which calls M-file']],...
		'function name','sfuncorr',...
		'parameters','npts,HowOften,offset,ts,0,''unbiased''',...
		'position',[160,48,225,82])
add_line([sys,'/','Auto Correlator'],[75,65;155,65])
set_param([sys,'/','Auto Correlator'],...
		'Mask Display','plot(0,0,100,100,[11,93,93,11,11],[90,90,40,40,90],[80,60,40,20],[50,79,50,80])',...
		'Mask Type','Autocorrelator.')
set_param([sys,'/','Auto Correlator'],...
		'Mask Dialogue','Auto correlator using graph window.\nRequires signal processing toolbox.|Length of buffer:|Plot after how many points:|Sample time:')
set_param([sys,'/','Auto Correlator'],...
		'Mask Translate','npts=@1; HowOften=@2; ts=@3(1); if length(@3) > 1, offset = @3(2), else, offset = 0; end')
set_param([sys,'/','Auto Correlator'],...
		'Mask Help','This block when hooked to the output of a system displays the auto correlation of the buffer in the graph window. For more see the M-file autocorr.',...
		'Mask Entries','100\/50\/0.1\/')


%     Finished composite block 'Auto Correlator'.

set_param([sys,'/','Auto Correlator'],...
		'Drop Shadow',4,...
		'position',[240,260,270,300])


%     Subsystem  ['Averaging',13,'Spectrum Analyzer'].

new_system([sys,'/',['Averaging',13,'Spectrum Analyzer']])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],'Location',[0,0,345,183])

add_block('built-in/Mux',[sys,'/',['Averaging',13,'Spectrum Analyzer/Mux']])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer/Mux']],...
		'inputs','2',...
		'position',[125,76,155,109])

add_block('built-in/Inport',[sys,'/',['Averaging',13,'Spectrum Analyzer/system output']])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer/system output']],...
		'Port','2',...
		'position',[35,115,55,135])

add_block('built-in/S-Function',[sys,'/',['Averaging',13,'Spectrum Analyzer/S-function block',13,'which calls M-file']])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer/S-function block',13,'which calls M-file']],...
		'function name','sfuntf',...
		'parameters','fftpts,npts,HowOften,offset,ts,1',...
		'position',[230,77,275,113])

add_block('built-in/Inport',[sys,'/',['Averaging',13,'Spectrum Analyzer/system input']])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer/system input']],...
		'position',[35,35,55,55])
add_line([sys,'/',['Averaging',13,'Spectrum Analyzer']],[60,125;90,125;90,100;120,100])
add_line([sys,'/',['Averaging',13,'Spectrum Analyzer']],[60,45;90,45;90,85;120,85])
add_line([sys,'/',['Averaging',13,'Spectrum Analyzer']],[160,95;225,95])
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Mask Display','plot(0,0,100,100,[12,92,92,12,12],[90,90,40,40,90],[80,72,63,54,47,40,32,20],[61,61,62,65,69,73,75,75])',...
		'Mask Type','Spectrum analayser.')
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Mask Dialogue','Spectrum analyser using graph window.\nHook input 1 to system input.\nHook input 2 to system output.|Length of buffer:|Number of points for fft:|Plot after how many points:|Sample time:')
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Mask Translate','npts=@1; fftpts=@2; HowOften=@3; ts=@4(1); if length(@4) > 1, offset = @4(2), else, offset = 0; end')
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Mask Help','Hook the system''s input to the first port of this block and the system''s output to second port. Results are displayed as the frequency response of this system. Use signals with high harmonic content for best results. ')
set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Mask Entries','256\/256\/64\/0.1\/')


%     Finished composite block ['Averaging',13,'Spectrum Analyzer'].

set_param([sys,'/',['Averaging',13,'Spectrum Analyzer']],...
		'Drop Shadow',4,...
		'position',[240,156,270,194])

add_block('built-in/Note',[sys,'/','Double click on DEMO blocks for example systems.'])
set_param([sys,'/','Double click on DEMO blocks for example systems.'],...
		'position',[170,335,175,340])

add_block('built-in/Note',[sys,'/','Analyzers'])
set_param([sys,'/','Analyzers'],...
		'position',[155,15,160,20])

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
