Simulink Communication Labs

by

 

This project allows you to learn communication systems in greater depth.

[ret,x0,str,ts,xts]=sdm(t,x,u,flag);
function [ret,x0,str,ts,xts]=sdm(t,x,u,flag);
%SDM	is the M-file description of the SIMULINK system named SDM.
%	The block-diagram can be displayed by typing: SDM.
%
%	SYS=SDM(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 SDM 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 SDM with a FLAG of zero:
%	[SIZES]=SDM([],[],[],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',[3000,3000,3160,3024])
     open_system(sys)
end;
set_param(sys,'algorithm',     'Linear')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '2')
set_param(sys,'Min step size', '1/512000')
set_param(sys,'Max step size', '1/512000')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'AssignWideVectorLines','on');


%     Subsystem  'Sign'.

new_system([sys,'/','Sign'])
set_param([sys,'/','Sign'],'Location',[159,417,467,586])

add_block('built-in/Outport',[sys,'/','Sign/out_1'])
set_param([sys,'/','Sign/out_1'],...
		'position',[265,70,285,90])

add_block('built-in/Inport',[sys,'/','Sign/in_1'])
set_param([sys,'/','Sign/in_1'],...
		'position',[35,30,55,50])

add_block('built-in/Relational Operator',[sys,'/',['Sign/Relational',13,'Operator']])
set_param([sys,'/',['Sign/Relational',13,'Operator']],...
		'Operator','>',...
		'position',[140,32,170,63])

add_block('built-in/Sum',[sys,'/','Sign/Sum'])
set_param([sys,'/','Sign/Sum'],...
		'inputs','+-',...
		'position',[215,64,235,91])

add_block('built-in/Relational Operator',[sys,'/',['Sign/Relational',13,'Operator1']])
set_param([sys,'/',['Sign/Relational',13,'Operator1']],...
		'Operator','<',...
		'position',[140,92,170,123])

add_block('built-in/Constant',[sys,'/','Sign/Constant'])
set_param([sys,'/','Sign/Constant'],...
		'Value','0',...
		'position',[65,105,85,125])
add_line([sys,'/','Sign'],[60,40;135,40])
add_line([sys,'/','Sign'],[95,40;95,100;135,100])
add_line([sys,'/','Sign'],[90,115;135,115])
add_line([sys,'/','Sign'],[110,115;110,55;135,55])
add_line([sys,'/','Sign'],[175,110;185,110;185,85;210,85])
add_line([sys,'/','Sign'],[175,50;185,50;185,70;210,70])
add_line([sys,'/','Sign'],[240,80;260,80])
set_param([sys,'/','Sign'],...
		'Mask Display','plot(-50,-50,50,50,[-50,50],[0,0],[0,0],[-50,50],[-40,0],[-30,-30],[0,40],[30,30])',...
		'Mask Type','Sign',...
		'Mask Dialogue','y = sign(x)')
set_param([sys,'/','Sign'],...
		'Mask Help','Sign Function:\n\t\t\ty = 1 if x > 0\n\t\t\ty = 0 if x = 0\n\t\t\ty = -1 if x < 0')


%     Finished composite block 'Sign'.

set_param([sys,'/','Sign'],...
		'position',[390,112,420,138])

add_block('built-in/Scope',[sys,'/','Scope2'])
set_param([sys,'/','Scope2'],...
		'Vgain','1.500000',...
		'Hgain','0.000050',...
		'Vmax','3.000000',...
		'Hmax','0.000100',...
		'Window',[0,197,770,397],...
		'position',[555,30,585,60])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'inputs','+-',...
		'position',[280,115,300,135])

add_block('built-in/Gain',[sys,'/','Gain'])
set_param([sys,'/','Gain'],...
		'Gain','.8',...
		'position',[170,105,200,135])


%     Subsystem  ['Repeating',13,'Sequence'].

new_system([sys,'/',['Repeating',13,'Sequence']])
set_param([sys,'/',['Repeating',13,'Sequence']],'Location',[5,40,315,196])

add_block('built-in/Clock',[sys,'/',['Repeating',13,'Sequence/Clock']])
set_param([sys,'/',['Repeating',13,'Sequence/Clock']],...
		'position',[45,60,65,80])

add_block('built-in/Fcn',[sys,'/',['Repeating',13,'Sequence/Fcn1']])
set_param([sys,'/',['Repeating',13,'Sequence/Fcn1']],...
		'Expr','rem(u[1],period)',...
		'position',[110,60,150,80])

add_block('built-in/Look Up Table',[sys,'/',['Repeating',13,'Sequence/Look-Up Table']])
set_param([sys,'/',['Repeating',13,'Sequence/Look-Up Table']],...
		'Input_Values','t',...
		'Output_Values','y',...
		'position',[210,58,250,82])

add_block('built-in/Outport',[sys,'/',['Repeating',13,'Sequence/out_1']])
set_param([sys,'/',['Repeating',13,'Sequence/out_1']],...
		'position',[285,60,305,80])
add_line([sys,'/',['Repeating',13,'Sequence']],[155,70;205,70])
add_line([sys,'/',['Repeating',13,'Sequence']],[70,70;105,70])
add_line([sys,'/',['Repeating',13,'Sequence']],[255,70;280,70])
set_param([sys,'/',['Repeating',13,'Sequence']],...
		'Mask Display','plot([t,t+period,t+2*period],[y,y,y])',...
		'Mask Type','Repeating table')
set_param([sys,'/',['Repeating',13,'Sequence']],...
		'Mask Dialogue','Repeating table.\nEnter values of time and output for first cycle.|Time values:|Output values:',...
		'Mask Translate','period = max(@1); t = @1; y = @2;')
set_param([sys,'/',['Repeating',13,'Sequence']],...
		'Mask Help','Repeats cycle given in table. Time values should be monotonically increasing.',...
		'Mask Entries','[0 .005 .005 .015 .015 .02]\/[1 1 -1 -1 1 1]\/')


%     Finished composite block ['Repeating',13,'Sequence'].

set_param([sys,'/',['Repeating',13,'Sequence']],...
		'position',[25,102,50,138])

add_block('built-in/Zero-Pole',[sys,'/',['Analog',13,'Butterworth',13,'LP Filter']])
set_param([sys,'/',['Analog',13,'Butterworth',13,'LP Filter']],...
		'Zeros','z',...
		'Poles','p',...
		'Gain','k',...
		'Mask Display','plot(20*log10(w),20*log10(abs(h)))',...
		'Mask Type','buttap')
set_param([sys,'/',['Analog',13,'Butterworth',13,'LP Filter']],...
		'Mask Dialogue','Analog Butterworth low pass filter.\n\n(Requires Signal Processing Toolbox)|Cutoff frequency (rad/sec)|Order')
set_param([sys,'/',['Analog',13,'Butterworth',13,'LP Filter']],...
		'Mask Translate','[z,p,k]=buttap(@2); z=@1*z; p=@1*p; k=real(prod(-p)); [num,den]=zp2tf(z,p,k); w=logspace(log10(@1/10),log10(10*@1),20); h=freqs(num,den,w); ')
set_param([sys,'/',['Analog',13,'Butterworth',13,'LP Filter']],...
		'Mask Help','Butterworth low pass filter using MATLAB''s butter command.',...
		'Mask Entries','400*2*pi\/5\/',...
		'position',[100,97,140,143])

add_block('built-in/Scope',[sys,'/','Scope3'])
set_param([sys,'/','Scope3'],...
		'Vgain','1.500000',...
		'Hgain','0.010000',...
		'Vmax','3.000000',...
		'Hmax','0.020000',...
		'Window',[381,0,770,198],...
		'position',[795,20,825,50])


%     Subsystem  'Decimation'.

new_system([sys,'/','Decimation'])
set_param([sys,'/','Decimation'],'Location',[129,578,559,704])

add_block('built-in/Zero-Order Hold',[sys,'/',['Decimation/Zero-Order',13,'Hold']])
set_param([sys,'/',['Decimation/Zero-Order',13,'Hold']],...
		'Sample time','ts*r',...
		'position',[225,39,260,71])

add_block('built-in/Inport',[sys,'/','Decimation/in_1'])
set_param([sys,'/','Decimation/in_1'],...
		'position',[45,45,65,65])

add_block('built-in/Outport',[sys,'/','Decimation/out_1'])
set_param([sys,'/','Decimation/out_1'],...
		'position',[290,45,310,65])

add_block('built-in/Discrete State-Space',[sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']])
set_param([sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']],...
		'A','a',...
		'B','b',...
		'C','c',...
		'D','d',...
		'Sample time','ts',...
		'Mask Display','plot(1:64,abs(h))',...
		'Mask Type','cheby1')
set_param([sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Dialogue','IIR Chebychev type I low pass filter.|Cutoff frequency (0 to 1):|Order:|Db ripple in passband:|Sample time:')
set_param([sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Translate','[a,b,c,d]=cheby1(@2,@3,@1); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Help','IIR Chebychev type I low pass filter designed using MATLAB''s cheby1 command. Implemented in state-space form. Filters of order 8 or less are implemented in controller canonical form for improved efficiency.')
set_param([sys,'/',['Decimation/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Entries','0.8/r\/8\/.05\/ts\/',...
		'position',[130,41,165,69])
add_line([sys,'/','Decimation'],[265,55;285,55])
add_line([sys,'/','Decimation'],[70,55;125,55])
add_line([sys,'/','Decimation'],[170,55;220,55])
set_param([sys,'/','Decimation'],...
		'Mask Display','x[nR]',...
		'Mask Type','Decimate',...
		'Mask Dialogue','Decimate input by integer factor.|Decimation factor R:|Input sample time:',...
		'Mask Translate','r=@1;ts=@2;')
set_param([sys,'/','Decimation'],...
		'Mask Help','Passes the input signal through an 8th order Chebyshev Type I IIR Lowpass filter with passband ripple of 0.05 dB to reduce aliasing. Subsamples the filtered signal at a rate R times slower than the base sample rate defined by the Sample time.')
set_param([sys,'/','Decimation'],...
		'Mask Entries','4\/1/512000\/')


%     Finished composite block 'Decimation'.

set_param([sys,'/','Decimation'],...
		'position',[550,109,590,141])


%     Subsystem  ['Dirty Square',13,'Wave1'].

new_system([sys,'/',['Dirty Square',13,'Wave1']])
set_param([sys,'/',['Dirty Square',13,'Wave1']],'Location',[125,385,604,706])

add_block('built-in/Sum',[sys,'/',['Dirty Square',13,'Wave1/Sum']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sum']],...
		'BackGround',3,...
		'inputs','+++++',...
		'position',[355,52,375,108])

add_block('built-in/Gain',[sys,'/',['Dirty Square',13,'Wave1/Gain3']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Gain3']],...
		'BackGround',3,...
		'Gain','1/9',...
		'position',[140,238,185,262])

add_block('built-in/Gain',[sys,'/',['Dirty Square',13,'Wave1/Gain2']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Gain2']],...
		'BackGround',3,...
		'Gain','1/7',...
		'position',[140,185,185,215])

add_block('built-in/Gain',[sys,'/',['Dirty Square',13,'Wave1/Gain1']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Gain1']],...
		'BackGround',3,...
		'Gain','1/5',...
		'position',[140,135,185,165])

add_block('built-in/Gain',[sys,'/',['Dirty Square',13,'Wave1/Gain']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Gain']],...
		'BackGround',3,...
		'Gain','1/3',...
		'position',[140,93,180,117])

add_block('built-in/Sine Wave',[sys,'/',['Dirty Square',13,'Wave1/Sine Wave4']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sine Wave4']],...
		'BackGround',3,...
		'frequency','6220.4',...
		'position',[60,240,80,260])

add_block('built-in/Sine Wave',[sys,'/',['Dirty Square',13,'Wave1/Sine Wave3']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sine Wave3']],...
		'BackGround',3,...
		'frequency','4838.1',...
		'position',[60,190,80,210])

add_block('built-in/Sine Wave',[sys,'/',['Dirty Square',13,'Wave1/Sine Wave2']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sine Wave2']],...
		'BackGround',3,...
		'frequency','3455.8',...
		'position',[60,140,80,160])

add_block('built-in/Sine Wave',[sys,'/',['Dirty Square',13,'Wave1/Sine Wave1']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sine Wave1']],...
		'BackGround',3,...
		'frequency','2073.5',...
		'position',[60,95,80,115])

add_block('built-in/Sine Wave',[sys,'/',['Dirty Square',13,'Wave1/Sine Wave']])
set_param([sys,'/',['Dirty Square',13,'Wave1/Sine Wave']],...
		'BackGround',3,...
		'frequency','691',...
		'sampletime','0',...
		'position',[60,50,80,70])

add_block('built-in/Outport',[sys,'/',['Dirty Square',13,'Wave1/out_1']])
set_param([sys,'/',['Dirty Square',13,'Wave1/out_1']],...
		'position',[420,70,440,90])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[380,80;415,80])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[190,250;325,250;325,100;350,100])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[190,200;305,200;305,90;350,90])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[190,150;285,150;285,80;350,80])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[185,105;255,105;255,70;350,70])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[85,60;350,60])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[85,250;135,250])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[85,200;135,200])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[85,150;135,150])
add_line([sys,'/',['Dirty Square',13,'Wave1']],[85,105;135,105])


%     Finished composite block ['Dirty Square',13,'Wave1'].

set_param([sys,'/',['Dirty Square',13,'Wave1']],...
		'position',[80,330,110,380])

add_block('built-in/Scope',[sys,'/','Scope4'])
set_param([sys,'/','Scope4'],...
		'Vgain','1.500000',...
		'Hgain','0.010000',...
		'Vmax','3.000000',...
		'Hmax','0.020000',...
		'Window',[0,397,383,597],...
		'position',[785,245,815,275])

add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
		'Vgain','1.500000',...
		'Hgain','0.010000',...
		'Vmax','3.000000',...
		'Hmax','0.020000',...
		'Window',[0,0,383,200],...
		'position',[245,30,275,60])

add_block('built-in/Zero-Order Hold',[sys,'/',['Zero-Order',13,'Hold']])
set_param([sys,'/',['Zero-Order',13,'Hold']],...
		'Sample time','1/512000',...
		'position',[455,109,490,141])

add_block('built-in/Integrator',[sys,'/','Integrator'])
set_param([sys,'/','Integrator'],...
		'position',[335,114,365,136])


%     Subsystem  'Decimation1'.

new_system([sys,'/','Decimation1'])
set_param([sys,'/','Decimation1'],'Location',[129,578,559,704])

add_block('built-in/Discrete State-Space',[sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']])
set_param([sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']],...
		'A','a',...
		'B','b',...
		'C','c',...
		'D','d',...
		'Sample time','ts',...
		'Mask Display','plot(1:64,abs(h))',...
		'Mask Type','cheby1')
set_param([sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Dialogue','IIR Chebychev type I low pass filter.|Cutoff frequency (0 to 1):|Order:|Db ripple in passband:|Sample time:')
set_param([sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Translate','[a,b,c,d]=cheby1(@2,@3,@1); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Help','IIR Chebychev type I low pass filter designed using MATLAB''s cheby1 command. Implemented in state-space form. Filters of order 8 or less are implemented in controller canonical form for improved efficiency.')
set_param([sys,'/',['Decimation1/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Entries','0.8/r\/8\/.05\/ts\/',...
		'position',[130,41,165,69])

add_block('built-in/Outport',[sys,'/','Decimation1/out_1'])
set_param([sys,'/','Decimation1/out_1'],...
		'position',[290,45,310,65])

add_block('built-in/Inport',[sys,'/','Decimation1/in_1'])
set_param([sys,'/','Decimation1/in_1'],...
		'position',[45,45,65,65])

add_block('built-in/Zero-Order Hold',[sys,'/',['Decimation1/Zero-Order',13,'Hold']])
set_param([sys,'/',['Decimation1/Zero-Order',13,'Hold']],...
		'Sample time','ts*r',...
		'position',[225,39,260,71])
add_line([sys,'/','Decimation1'],[170,55;220,55])
add_line([sys,'/','Decimation1'],[70,55;125,55])
add_line([sys,'/','Decimation1'],[265,55;285,55])
set_param([sys,'/','Decimation1'],...
		'Mask Display','x[nR]',...
		'Mask Type','Decimate',...
		'Mask Dialogue','Decimate input by integer factor.|Decimation factor R:|Input sample time:',...
		'Mask Translate','r=@1;ts=@2;')
set_param([sys,'/','Decimation1'],...
		'Mask Help','Passes the input signal through an 8th order Chebyshev Type I IIR Lowpass filter with passband ripple of 0.05 dB to reduce aliasing. Subsamples the filtered signal at a rate R times slower than the base sample rate defined by the Sample time.')
set_param([sys,'/','Decimation1'],...
		'Mask Entries','4\/1/128000\/')


%     Finished composite block 'Decimation1'.

set_param([sys,'/','Decimation1'],...
		'position',[640,109,680,141])


%     Subsystem  'Decimation2'.

new_system([sys,'/','Decimation2'])
set_param([sys,'/','Decimation2'],'Location',[129,578,559,704])

add_block('built-in/Zero-Order Hold',[sys,'/',['Decimation2/Zero-Order',13,'Hold']])
set_param([sys,'/',['Decimation2/Zero-Order',13,'Hold']],...
		'Sample time','ts*r',...
		'position',[225,39,260,71])

add_block('built-in/Inport',[sys,'/','Decimation2/in_1'])
set_param([sys,'/','Decimation2/in_1'],...
		'position',[45,45,65,65])

add_block('built-in/Outport',[sys,'/','Decimation2/out_1'])
set_param([sys,'/','Decimation2/out_1'],...
		'position',[290,45,310,65])

add_block('built-in/Discrete State-Space',[sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']])
set_param([sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']],...
		'A','a',...
		'B','b',...
		'C','c',...
		'D','d',...
		'Sample time','ts',...
		'Mask Display','plot(1:64,abs(h))',...
		'Mask Type','cheby1')
set_param([sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Dialogue','IIR Chebychev type I low pass filter.|Cutoff frequency (0 to 1):|Order:|Db ripple in passband:|Sample time:')
set_param([sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Translate','[a,b,c,d]=cheby1(@2,@3,@1); ts=@4; [num,den]=ss2tf(a,b,c,d,1); if (@2 <= 8), [a,b,c,d]=tf2ss(num,den); end; h=freqz(num,den,64); ')
set_param([sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Help','IIR Chebychev type I low pass filter designed using MATLAB''s cheby1 command. Implemented in state-space form. Filters of order 8 or less are implemented in controller canonical form for improved efficiency.')
set_param([sys,'/',['Decimation2/Chebyshev Type I',13,'IIR Lowpass']],...
		'Mask Entries','0.8/r\/8\/.05\/ts\/',...
		'position',[130,41,165,69])
add_line([sys,'/','Decimation2'],[265,55;285,55])
add_line([sys,'/','Decimation2'],[70,55;125,55])
add_line([sys,'/','Decimation2'],[170,55;220,55])
set_param([sys,'/','Decimation2'],...
		'Mask Display','x[nR]',...
		'Mask Type','Decimate',...
		'Mask Dialogue','Decimate input by integer factor.|Decimation factor R:|Input sample time:',...
		'Mask Translate','r=@1;ts=@2;')
set_param([sys,'/','Decimation2'],...
		'Mask Help','Passes the input signal through an 8th order Chebyshev Type I IIR Lowpass filter with passband ripple of 0.05 dB to reduce aliasing. Subsamples the filtered signal at a rate R times slower than the base sample rate defined by the Sample time.')
set_param([sys,'/','Decimation2'],...
		'Mask Entries','4\/1/32000\/')


%     Finished composite block 'Decimation2'.

set_param([sys,'/','Decimation2'],...
		'position',[735,109,775,141])

add_block('built-in/Scope',[sys,'/','Scope5'])
set_param([sys,'/','Scope5'],...
		'Vgain','1.500000',...
		'Hgain','0.010000',...
		'Vmax','3.000000',...
		'Hmax','0.020000',...
		'Window',[381,397,770,596],...
		'position',[755,175,785,205])
add_line(sys,[425,125;450,125])
add_line(sys,[495,125;520,125;520,45;550,45])
add_line(sys,[305,125;330,125])
add_line(sys,[370,125;385,125])
add_line(sys,[495,125;510,125;510,185;260,185;260,130;275,130])
add_line(sys,[595,125;635,125])
add_line(sys,[685,125;730,125])
add_line(sys,[55,120;95,120])
add_line(sys,[510,125;545,125])
add_line(sys,[780,125;790,35])
add_line(sys,[205,120;275,120])
add_line(sys,[220,120;220,45;240,45])
add_line(sys,[145,120;165,120])
add_line(sys,[595,125;610,125;610,260;780,260])
add_line(sys,[685,125;710,125;710,190;750,190])

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

Contact us