function [ret,x0,str,ts,xts]=digcom2(t,x,u,flag);
%DIGCOM2	is the M-file description of the SIMULINK system named DIGCOM2.
%	The block-diagram can be displayed by typing: DIGCOM2.
%
%	SYS=DIGCOM2(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 DIGCOM2 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 DIGCOM2 with a FLAG of zero:
%	[SIZES]=DIGCOM2([],[],[],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',[21,65,1041,684])
     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', 'dt')
set_param(sys,'Max step size', 'dt')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')


%     Subsystem  ['Eye-diagram',13,'With Filter'].

new_system([sys,'/',['Eye-diagram',13,'With Filter']])
set_param([sys,'/',['Eye-diagram',13,'With Filter']],'Location',[165,242,460,428])

add_block('built-in/S-Function',[sys,'/',['Eye-diagram',13,'With Filter/Plot1']])
set_param([sys,'/',['Eye-diagram',13,'With Filter/Plot1']],...
		'function name','eyediasi',...
		'parameters','time_range, boundary, kept_length, eye_line, scatter_line, two_d_line',...
		'position',[130,70,200,110])

add_block('built-in/Mux',[sys,'/',['Eye-diagram',13,'With Filter/Mux']])
set_param([sys,'/',['Eye-diagram',13,'With Filter/Mux']],...
		'inputs','2',...
		'position',[65,70,100,105])

add_block('built-in/Inport',[sys,'/',['Eye-diagram',13,'With Filter/in_2']])
set_param([sys,'/',['Eye-diagram',13,'With Filter/in_2']],...
		'Port','2',...
		'position',[20,115,40,135])

add_block('built-in/Inport',[sys,'/',['Eye-diagram',13,'With Filter/in_1']])
set_param([sys,'/',['Eye-diagram',13,'With Filter/in_1']],...
		'position',[15,55,35,75])
add_line([sys,'/',['Eye-diagram',13,'With Filter']],[105,90;125,90])
add_line([sys,'/',['Eye-diagram',13,'With Filter']],[45,125;50,125;60,95])
add_line([sys,'/',['Eye-diagram',13,'With Filter']],[40,65;45,65;45,80;60,80])
set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);',...
		'Mask Type','Eye-diagram/scatter plot')
set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'Mask Dialogue','Produce eye-pattern diagram/scatter\nplot/x-y plot with the rising edge of the second input as the decision line.|Eye-pattern plot time frame:|Lower and upper bound of in-coming signal (1x2 vector):|Number of saved traces:|Line-type for eye-pattern diagram (0 for no plot):|Line-type for scatter plot (0 for no plot):|Line-type for x-y plot (0 for no plot):')
set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'Mask Translate','time_range=@1;boundary=@2;kept_length=@3;eye_line=@4;scatter_line=@5;two_d_line=@6;[x,y]=srcsicon(10);[v,w]=trigicon(0,25,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'Mask Help','This plot opens one, two, or three plots by assigning the line type parameters. The scatter plot point is selected by the rising edge of a trigger signal. A decision line is drawn at the rising edge of the trigger signal.')
set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'Mask Entries','2*T\/[-2,2]\/50\/''r-/g--/b-.''\/0\/0\/')


%     Finished composite block ['Eye-diagram',13,'With Filter'].

set_param([sys,'/',['Eye-diagram',13,'With Filter']],...
		'position',[685,378,765,422])

add_block('built-in/Constant',[sys,'/','Constant'])
set_param([sys,'/','Constant'],...
		'Value','h',...
		'position',[555,265,575,285])


%     Subsystem  ['Inner',13,'Product'].

new_system([sys,'/',['Inner',13,'Product']])
set_param([sys,'/',['Inner',13,'Product']],'Location',[33,479,253,634])

add_block('built-in/Product',[sys,'/',['Inner',13,'Product/Product']])
set_param([sys,'/',['Inner',13,'Product/Product']],...
		'position',[65,55,90,75])

add_block('built-in/Sum',[sys,'/',['Inner',13,'Product/Sum']])
set_param([sys,'/',['Inner',13,'Product/Sum']],...
		'inputs','+',...
		'position',[125,55,145,75])

add_block('built-in/Outport',[sys,'/',['Inner',13,'Product/out_1']])
set_param([sys,'/',['Inner',13,'Product/out_1']],...
		'position',[185,55,205,75])

add_block('built-in/Inport',[sys,'/',['Inner',13,'Product/in_2']])
set_param([sys,'/',['Inner',13,'Product/in_2']],...
		'Port','2',...
		'position',[15,90,35,110])

add_block('built-in/Inport',[sys,'/',['Inner',13,'Product/in_1']])
set_param([sys,'/',['Inner',13,'Product/in_1']],...
		'position',[15,25,35,45])
add_line([sys,'/',['Inner',13,'Product']],[40,100;60,70])
add_line([sys,'/',['Inner',13,'Product']],[40,35;60,60])
add_line([sys,'/',['Inner',13,'Product']],[95,65;120,65])
add_line([sys,'/',['Inner',13,'Product']],[150,65;180,65])
set_param([sys,'/',['Inner',13,'Product']],...
		'Mask Display','.\n',...
		'Mask Type','Dot Product',...
		'Mask Dialogue','Inner (dot) product.\ny=sum(u1.*u2)')
set_param([sys,'/',['Inner',13,'Product']],...
		'Mask Help','Computes the inner (dot) product of the inputs: sum(u1.*u2).  The inputs are vectors of the same length. Output is a scalar.')


%     Finished composite block ['Inner',13,'Product'].

set_param([sys,'/',['Inner',13,'Product']],...
		'position',[600,214,620,236])


%     Subsystem  'EM: With Filter'.

new_system([sys,'/','EM: With Filter'])
set_param([sys,'/','EM: With Filter'],'Location',[255,368,509,510])

add_block('built-in/S-Function',[sys,'/','EM: With Filter/S-function'])
set_param([sys,'/','EM: With Filter/S-function'],...
		'function name','sbiterr',...
		'parameters','num_lin, K, TDelay, Sample',...
		'position',[130,52,195,78])

add_block('built-in/Mux',[sys,'/','EM: With Filter/Mux'])
set_param([sys,'/','EM: With Filter/Mux'],...
		'inputs','2',...
		'position',[65,46,100,79])

add_block('built-in/Inport',[sys,'/','EM: With Filter/in_1'])
set_param([sys,'/','EM: With Filter/in_1'],...
		'position',[15,45,35,65])

add_block('built-in/Inport',[sys,'/','EM: With Filter/in_2'])
set_param([sys,'/','EM: With Filter/in_2'],...
		'Port','2',...
		'position',[15,60,35,80])
add_line([sys,'/','EM: With Filter'],[105,65;125,65])
add_line([sys,'/','EM: With Filter'],[40,55;60,55])
add_line([sys,'/','EM: With Filter'],[40,70;60,70])
set_param([sys,'/','EM: With Filter'],...
		'Mask Display','Error\nmeter',...
		'Mask Type','Symbol/bit error counter')
set_param([sys,'/','EM: With Filter'],...
		'Mask Dialogue','Use the input data from the 1st port as the reference signal to detect the number of errors and error rate of the 2nd signal.|Bit per symbol:|Number of digits on display:|Delay between 1st port and 2nd port:|Sample time (sec):')
set_param([sys,'/','EM: With Filter'],...
		'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','EM: With Filter'],...
		'Mask Help','The signal from the first port must be a scalar. The second input port can be a vector with a delay to the first port signal. The comparison happens only at the sampling point.')
set_param([sys,'/','EM: With Filter'],...
		'Mask Entries','1\/10\/T/2\/T\/')


%     Finished composite block 'EM: With Filter'.

set_param([sys,'/','EM: With Filter'],...
		'position',[830,213,910,257])


%     Subsystem  'MASK demap: MF'.

new_system([sys,'/','MASK demap: MF'])
set_param([sys,'/','MASK demap: MF'],'Location',[187,342,628,482])

add_block('built-in/Zero-Order Hold',[sys,'/',['MASK demap: MF/Zero-Order',13,'Hold']])
set_param([sys,'/',['MASK demap: MF/Zero-Order',13,'Hold']],...
		'Sample time','td',...
		'position',[85,29,120,61])

add_block('built-in/Constant',[sys,'/','MASK demap: MF/Shift key'])
set_param([sys,'/','MASK demap: MF/Shift key'],...
		'Value','sft',...
		'position',[115,93,135,117])

add_block('built-in/Sum',[sys,'/','MASK demap: MF/Sum2'])
set_param([sys,'/','MASK demap: MF/Sum2'],...
		'inputs','+-',...
		'position',[180,38,200,67])

add_block('built-in/Abs',[sys,'/','MASK demap: MF/Abs'])
set_param([sys,'/','MASK demap: MF/Abs'],...
		'position',[235,42,270,68])

add_block('built-in/Outport',[sys,'/','MASK demap: MF/out_1'])
set_param([sys,'/','MASK demap: MF/out_1'],...
		'position',[400,45,420,65])

add_block('built-in/S-Function',[sys,'/','MASK demap: MF/Minimum'])
set_param([sys,'/','MASK demap: MF/Minimum'],...
		'function name','arymimai',...
		'parameters','''min''',...
		'position',[315,45,370,65])

add_block('built-in/Inport',[sys,'/','MASK demap: MF/in_1'])
set_param([sys,'/','MASK demap: MF/in_1'],...
		'position',[30,35,50,55])
add_line([sys,'/','MASK demap: MF'],[55,45;80,45])
add_line([sys,'/','MASK demap: MF'],[275,55;310,55])
add_line([sys,'/','MASK demap: MF'],[125,45;175,45])
add_line([sys,'/','MASK demap: MF'],[375,55;395,55])
add_line([sys,'/','MASK demap: MF'],[140,105;155,105;155,60;175,60])
add_line([sys,'/','MASK demap: MF'],[205,55;230,55])
set_param([sys,'/','MASK demap: MF'],...
		'Mask Display','MASK\ndemap',...
		'Mask Type','MASK demap')
set_param([sys,'/','MASK demap: MF'],...
		'Mask Dialogue','Reverse the MASK mapping process\nConvert [-1 1] analog signal to [0, M-1] symbols.|M-ary number (digit integers in ranger [0, M-1]):|Output symbol interval and offset (sec):')
set_param([sys,'/','MASK demap: MF'],...
		'Mask Translate','N=@1;Ac=1;sft=[0:N-1]*Ac*2/(N-1)-Ac;td=@2;')
set_param([sys,'/','MASK demap: MF'],...
		'Mask Help','This block demaps a MASK mapped signal back to digit symbols. You can place this block after a amplitude demodulation block. The input of this block is an analog signal in the range [-1, 1]. The demodulation decides the closest integer fitting in [0,M-1] range. When the input symbol interval is a two-elements vector, the second element is offset. The default offset value is 0.')
set_param([sys,'/','MASK demap: MF'],...
		'Mask Entries','2\/[T, 0.9*T]\/')


%     Finished composite block 'MASK demap: MF'.

set_param([sys,'/','MASK demap: MF'],...
		'position',[665,213,745,257])


%     Subsystem  'Buffer'.

new_system([sys,'/','Buffer'])
set_param([sys,'/','Buffer'],'Location',[486,410,806,564])

add_block('built-in/S-Function',[sys,'/','Buffer/ZOH'])
set_param([sys,'/','Buffer/ZOH'],...
		'function name','szoh',...
		'parameters','sampleTime(2,:)',...
		'position',[220,43,260,67])

add_block('built-in/Outport',[sys,'/','Buffer/Outport'])
set_param([sys,'/','Buffer/Outport'],...
		'position',[285,45,305,65])

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

add_block('built-in/S-Function',[sys,'/','Buffer/Buffer'])
set_param([sys,'/','Buffer/Buffer'],...
		'function name','sbuffer',...
		'parameters','bufSize,bufOverlap,sampleTime',...
		'position',[120,34,195,76])

add_block('built-in/Zero-Order Hold',[sys,'/',['Buffer/Zero-Order',13,'Hold']])
set_param([sys,'/',['Buffer/Zero-Order',13,'Hold']],...
		'Sample time','sampleTime(1,:)',...
		'position',[60,39,95,71])
add_line([sys,'/','Buffer'],[100,55;115,55])
add_line([sys,'/','Buffer'],[35,55;55,55])
add_line([sys,'/','Buffer'],[265,55;280,55])
add_line([sys,'/','Buffer'],[200,55;215,55])
set_param([sys,'/','Buffer'],...
		'Mask Display','plot(0,0,100,100,[12 28 28 32 28 28],[92 92 94 92 90 92],[32 36 36 40 36 36],[92 92 94 92 90 92],[24 24 28],[92 92 92],[40 44 44 48 44 44],[92 92 94 92 90 92],[52 48 52 52 56 52 52],[92 92 92 94 92 90 92],[56 64 64 57 64 71],[92 92 69 76 69 76],[48 80 80 48 48],[64 64 12 12 64],[56 72],[56 56],[56 72],[48 48],[56 72],[40 40],[56 72],[32 32],[56 72],[24 24])')
set_param([sys,'/','Buffer'],...
		'Mask Type','Buffer',...
		'Mask Dialogue','Buffer input data.|Buffer size:|Buffer overlap:|Sample time:',...
		'Mask Translate','bufSize=@1;bufOverlap=@2;sampleTime=dspbufst( @3, @1-@2, @1 - 1);')
set_param([sys,'/','Buffer'],...
		'Mask Help','Accumulates samples (at a sampling interval of Sample time) of the real scalar input into a buffer of length Buffer size. Outputs the content of the buffer in a real vector. Updates the buffer every (Buffer size - Buffer overlap) samples, outputting a frame of the input which overlaps the previous frame by Buffer overlap samples.  Buffer overlap may be zero or negative.')
set_param([sys,'/','Buffer'],...
		'Mask Entries','T/dt\/T/dt-1\/dt\/')


%     Finished composite block 'Buffer'.

set_param([sys,'/','Buffer'],...
		'position',[515,214,555,246])


%     Subsystem  'GR: With Filter'.

new_system([sys,'/','GR: With Filter'])
set_param([sys,'/','GR: With Filter'],'Location',[0,59,274,252])

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

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


%     Finished composite block 'GR: With Filter'.

set_param([sys,'/','GR: With Filter'],...
		'position',[795,151,825,189])

add_block('built-in/Mux',[sys,'/','Mux: w// '])
set_param([sys,'/','Mux: w// '],...
		'inputs','2',...
		'position',[705,151,735,184])


%     Subsystem  ['Sampled read with',13,'synchronized pulse'].

new_system([sys,'/',['Sampled read with',13,'synchronized pulse']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],'Location',[355,527,737,674])


%     Subsystem  ['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1'].

new_system([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],'Location',[55,192,283,286])

add_block('built-in/S-Function',[sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1/S-function1']],...
		'function name','homopuls',...
		'parameters','samp_time, out_divid, offset',...
		'position',[40,31,105,59])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1/Outport']],...
		'position',[160,35,180,55])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'Mask Display','Vector\nPulse',...
		'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time ./Divider. |Sample time (scalar, sec):|Divider (integer vector):|Offset (have same dimension as Divider:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'Mask Help','This block generator a vector pulses. The output length is the same as the vector defined in "Divider". The ith element of the output has the sample time Sample_time/Divider(i). All elements in "Divider" must be integers.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'Mask Entries','ts\/1\/off\/')


%     Finished composite block ['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1'].

set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Pulses deivide',13,'same sample time1']],...
		'position',[50,56,110,94])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse/out_1']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/out_1']],...
		'position',[295,65,315,85])

add_block('built-in/Outport',[sys,'/',['Sampled read with',13,'synchronized pulse/out_2']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/out_2']],...
		'Port','2',...
		'position',[195,115,215,135])

add_block('built-in/S-Function',[sys,'/',['Sampled read with',13,'synchronized pulse/Message source']])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'BackGround',5,...
		'function name','trigwksp',...
		'parameters','var,thd,cyclFlag,ini',...
		'Mask Display','Triggered\nread')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'Mask Dialogue','The raising edge of input pulse trigger the block output the next row from the workspace variable.|Read the variable:|Threshold for the input pulse:|Cyclic read variable (1) or amend zeros (0).|Output before first trigger:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'Mask Help','This block reads the data from a workspace variable. The output is refreshed at the raising edge of the input pulse.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse/Message source']],...
		'Mask Entries','var\/.1\/cyc\/ini\/',...
		'position',[180,53,255,97])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse']],[260,75;290,75])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse']],[115,75;175,75])
add_line([sys,'/',['Sampled read with',13,'synchronized pulse']],[135,75;135,125;190,125])
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);Rd wksp',...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'Mask Dialogue','Read from a workspace variable at\nsampling time point.|Variable (column_number=block_output_length):|Data output sample time (sec):|Cyclic control (1: cyclic read, 0: output zeros after eof).|Initial output:')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'Mask Translate','var=@1;td=@2;ts=td(1);if (length(td)>=2),off=td(2);else off=0;end;cyc=@3;ini=@4;[x,y]=srcsicon(7);[v,w]=trigicon(1,75,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'Mask Help','This block reads from a workspace variable at a given sample time. The column number is the block output vector length. When the simulation reaches the end of the variable (eof) row, the block will cyclically output from the first row of the variable or output zeros based on the cyclic control entree. The second output is the synchronization pulse, which outputs a spike when the data is refreshed.')
set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'Mask Entries','randint(300,1,2)\/T\/1\/0\/')


%     Finished composite block ['Sampled read with',13,'synchronized pulse'].

set_param([sys,'/',['Sampled read with',13,'synchronized pulse']],...
		'hide name',0,...
		'position',[35,218,115,262])


%     Subsystem  ['AWGN',13,'channel'].

new_system([sys,'/',['AWGN',13,'channel']])
set_param([sys,'/',['AWGN',13,'channel']],'Location',[86,493,348,639])

add_block('built-in/Inport',[sys,'/',['AWGN',13,'channel/in_1']])
set_param([sys,'/',['AWGN',13,'channel/in_1']],...
		'position',[45,10,65,30])


%     Subsystem  ['AWGN',13,'channel/Gaussian',13,'noise'].

new_system([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],'Location',[409,168,757,373])

add_block('built-in/White Noise',[sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Random',13,'Number']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Random',13,'Number']],...
		'Seed','s',...
		'position',[45,102,90,138])

add_block('built-in/Constant',[sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Constant']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Constant']],...
		'Value','m',...
		'position',[55,55,75,75])

add_block('built-in/Sum',[sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Sum']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Sum']],...
		'position',[140,85,160,105])

add_block('built-in/Outport',[sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/out_1']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/out_1']],...
		'position',[295,85,315,105])

add_block('built-in/State-Space',[sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Matrix',13,'Gain']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Matrix',13,'Gain']],...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Matrix',13,'Gain']],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','d\/')
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise/Matrix',13,'Gain']],...
		'position',[210,81,235,109])
add_line([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],[80,65;110,65;110,90;135,90])
add_line([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],[95,120;110,120;110,100;135,100])
add_line([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],[165,95;205,95])
add_line([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],[240,95;290,95])
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],...
		'Mask Display','Gaussian\nnoise',...
		'Mask Type','Gaussian noise.',...
		'Mask Dialogue','Gaussian distribution noise.|Mean value:|Standard deviation:|Initial Seed(s):')
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],...
		'Mask Translate','m=@1;d=@2;s=@3;[m,d,s]=gwnoise(m,d,s);')
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],...
		'Mask Help','When the mean value, seed are vectors, the output of this block is a vector with the length of the vector same as the length of mean value vector or that of the seed.')
set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],...
		'Mask Entries','m\/d\/s\/')


%     Finished composite block ['AWGN',13,'channel/Gaussian',13,'noise'].

set_param([sys,'/',['AWGN',13,'channel/Gaussian',13,'noise']],...
		'position',[10,50,85,90])

add_block('built-in/Outport',[sys,'/',['AWGN',13,'channel/out_1']])
set_param([sys,'/',['AWGN',13,'channel/out_1']],...
		'position',[200,55,220,75])

add_block('built-in/Sum',[sys,'/',['AWGN',13,'channel/Sum']])
set_param([sys,'/',['AWGN',13,'channel/Sum']],...
		'position',[150,55,170,75])
add_line([sys,'/',['AWGN',13,'channel']],[175,65;195,65])
add_line([sys,'/',['AWGN',13,'channel']],[70,20;115,20;115,60;145,60])
add_line([sys,'/',['AWGN',13,'channel']],[90,70;145,70])
set_param([sys,'/',['AWGN',13,'channel']],...
		'Mask Display','plot(0,0,100,100,x,y);AWGN',...
		'Mask Type','AWGN channel, fixed parameter')
set_param([sys,'/',['AWGN',13,'channel']],...
		'Mask Dialogue','Additive white Gaussian noise channel\nwith fixed mean and variance.|Mean value:|Variance (std^2):|Initial Seed:')
set_param([sys,'/',['AWGN',13,'channel']],...
		'Mask Translate','m=@1;d=@2;s=@3;[m,d,s]=gwnoise(m,d,s);[x,y]=chanicon;')
set_param([sys,'/',['AWGN',13,'channel']],...
		'Mask Help','This block adds white Gaussian noise to the input signal. The mean and the variance can be a scalar or vector with the same length as the input signal.')
set_param([sys,'/',['AWGN',13,'channel']],...
		'Mask Entries','0\/1.0\/12345\/')


%     Finished composite block ['AWGN',13,'channel'].

set_param([sys,'/',['AWGN',13,'channel']],...
		'position',[410,208,490,252])

add_block('built-in/Transfer Fcn',[sys,'/','RC circuit'])
set_param([sys,'/','RC circuit'],...
		'Denominator','[1/(100) 1]',...
		'position',[285,197,370,263])


%     Subsystem  'MASK map'.

new_system([sys,'/','MASK map'])
set_param([sys,'/','MASK map'],'Location',[520,162,902,335])

add_block('built-in/Outport',[sys,'/','MASK map/out_1'])
set_param([sys,'/','MASK map/out_1'],...
		'position',[315,65,335,85])

add_block('built-in/Zero-Order Hold',[sys,'/',['MASK map/Zero-Order',13,'Hold']])
set_param([sys,'/',['MASK map/Zero-Order',13,'Hold']],...
		'Sample time','td',...
		'position',[100,24,135,56])

add_block('built-in/Inport',[sys,'/','MASK map/in_1'])
set_param([sys,'/','MASK map/in_1'],...
		'position',[40,30,60,50])

add_block('built-in/Gain',[sys,'/','MASK map/Gain'])
set_param([sys,'/','MASK map/Gain'],...
		'Gain','Kc',...
		'position',[180,25,220,55])

add_block('built-in/Sum',[sys,'/','MASK map/Sum1'])
set_param([sys,'/','MASK map/Sum1'],...
		'inputs','+-',...
		'position',[250,63,270,87])

add_block('built-in/Constant',[sys,'/','MASK map/Gain diff'])
set_param([sys,'/','MASK map/Gain diff'],...
		'Value','Ac',...
		'position',[180,96,215,124])
add_line([sys,'/','MASK map'],[225,40;230,40;230,70;245,70])
add_line([sys,'/','MASK map'],[220,110;230,110;230,80;245,80])
add_line([sys,'/','MASK map'],[275,75;310,75])
add_line([sys,'/','MASK map'],[65,40;95,40])
add_line([sys,'/','MASK map'],[140,40;175,40])
set_param([sys,'/','MASK map'],...
		'Mask Display','MASK\nmap',...
		'Mask Type','MASK map')
set_param([sys,'/','MASK map'],...
		'Mask Dialogue','Map a digital symbol onto an analog\nsignal in the range [-1, 1] using M-ary\namplitude shift keying modulation mapping.|M-ary number (input integers in range [0, M-1]):|Input symbol interval and offset (sec):')
set_param([sys,'/','MASK map'],...
		'Mask Translate','N=@1;Ac=1;Kc=Ac*2/(N-1);td=@2;')
set_param([sys,'/','MASK map'],...
		'Mask Help','This block maps an input digit signal onto a signal in the range [-1, 1]. The coded signal can be modulated using analog\nmodulation blocks. Input digits are in the range [0, M-1], where M is the M-ary number. The input symbol interval can be a two-element vector with the second element being offset. The default value offset is 0. Use the MODMAP function to see the constellation.')
set_param([sys,'/','MASK map'],...
		'Mask Entries','2\/[T,0]\/')


%     Finished composite block 'MASK map'.

set_param([sys,'/','MASK map'],...
		'position',[170,208,250,252])

add_block('built-in/Mux',[sys,'/','Mux: w//out'])
set_param([sys,'/','Mux: w//out'],...
		'inputs','2',...
		'position',[705,86,735,119])


%     Subsystem  'GR: Without Filter'.

new_system([sys,'/','GR: Without Filter'])
set_param([sys,'/','GR: Without Filter'],'Location',[0,59,274,252])

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

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


%     Finished composite block 'GR: Without Filter'.

set_param([sys,'/','GR: Without Filter'],...
		'position',[790,86,820,124])


%     Subsystem  'EM: Without Filter'.

new_system([sys,'/','EM: Without Filter'])
set_param([sys,'/','EM: Without Filter'],'Location',[255,368,509,510])

add_block('built-in/S-Function',[sys,'/','EM: Without Filter/S-function'])
set_param([sys,'/','EM: Without Filter/S-function'],...
		'function name','sbiterr',...
		'parameters','num_lin, K, TDelay, Sample',...
		'position',[130,52,195,78])

add_block('built-in/Mux',[sys,'/','EM: Without Filter/Mux'])
set_param([sys,'/','EM: Without Filter/Mux'],...
		'inputs','2',...
		'position',[65,46,100,79])

add_block('built-in/Inport',[sys,'/','EM: Without Filter/in_1'])
set_param([sys,'/','EM: Without Filter/in_1'],...
		'position',[15,45,35,65])

add_block('built-in/Inport',[sys,'/','EM: Without Filter/in_2'])
set_param([sys,'/','EM: Without Filter/in_2'],...
		'Port','2',...
		'position',[15,60,35,80])
add_line([sys,'/','EM: Without Filter'],[105,65;125,65])
add_line([sys,'/','EM: Without Filter'],[40,55;60,55])
add_line([sys,'/','EM: Without Filter'],[40,70;60,70])
set_param([sys,'/','EM: Without Filter'],...
		'Mask Display','Error\nmeter',...
		'Mask Type','Symbol/bit error counter')
set_param([sys,'/','EM: Without Filter'],...
		'Mask Dialogue','Use the input data from the 1st port as the reference signal to detect the number of errors and error rate of the 2nd signal.|Bit per symbol:|Number of digits on display:|Delay between 1st port and 2nd port:|Sample time (sec):')
set_param([sys,'/','EM: Without Filter'],...
		'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','EM: Without Filter'],...
		'Mask Help','The signal from the first port must be a scalar. The second input port can be a vector with a delay to the first port signal. The comparison happens only at the sampling point.')
set_param([sys,'/','EM: Without Filter'],...
		'Mask Entries','1\/10\/T/2\/T\/')


%     Finished composite block 'EM: Without Filter'.

set_param([sys,'/','EM: Without Filter'],...
		'position',[690,473,770,517])


%     Subsystem  'MASK demap: MF1'.

new_system([sys,'/','MASK demap: MF1'])
set_param([sys,'/','MASK demap: MF1'],'Location',[187,342,628,482])

add_block('built-in/Zero-Order Hold',[sys,'/',['MASK demap: MF1/Zero-Order',13,'Hold']])
set_param([sys,'/',['MASK demap: MF1/Zero-Order',13,'Hold']],...
		'Sample time','td',...
		'position',[85,29,120,61])

add_block('built-in/Constant',[sys,'/','MASK demap: MF1/Shift key'])
set_param([sys,'/','MASK demap: MF1/Shift key'],...
		'Value','sft',...
		'position',[115,93,135,117])

add_block('built-in/Sum',[sys,'/','MASK demap: MF1/Sum2'])
set_param([sys,'/','MASK demap: MF1/Sum2'],...
		'inputs','+-',...
		'position',[180,38,200,67])

add_block('built-in/Abs',[sys,'/','MASK demap: MF1/Abs'])
set_param([sys,'/','MASK demap: MF1/Abs'],...
		'position',[235,42,270,68])

add_block('built-in/Outport',[sys,'/','MASK demap: MF1/out_1'])
set_param([sys,'/','MASK demap: MF1/out_1'],...
		'position',[400,45,420,65])

add_block('built-in/S-Function',[sys,'/','MASK demap: MF1/Minimum'])
set_param([sys,'/','MASK demap: MF1/Minimum'],...
		'function name','arymimai',...
		'parameters','''min''',...
		'position',[315,45,370,65])

add_block('built-in/Inport',[sys,'/','MASK demap: MF1/in_1'])
set_param([sys,'/','MASK demap: MF1/in_1'],...
		'position',[30,35,50,55])
add_line([sys,'/','MASK demap: MF1'],[55,45;80,45])
add_line([sys,'/','MASK demap: MF1'],[275,55;310,55])
add_line([sys,'/','MASK demap: MF1'],[125,45;175,45])
add_line([sys,'/','MASK demap: MF1'],[375,55;395,55])
add_line([sys,'/','MASK demap: MF1'],[140,105;155,105;155,60;175,60])
add_line([sys,'/','MASK demap: MF1'],[205,55;230,55])
set_param([sys,'/','MASK demap: MF1'],...
		'Mask Display','MASK\ndemap',...
		'Mask Type','MASK demap')
set_param([sys,'/','MASK demap: MF1'],...
		'Mask Dialogue','Reverse the MASK mapping process\nConvert [-1 1] analog signal to [0, M-1] symbols.|M-ary number (digit integers in ranger [0, M-1]):|Output symbol interval and offset (sec):')
set_param([sys,'/','MASK demap: MF1'],...
		'Mask Translate','N=@1;Ac=1;sft=[0:N-1]*Ac*2/(N-1)-Ac;td=@2;')
set_param([sys,'/','MASK demap: MF1'],...
		'Mask Help','This block demaps a MASK mapped signal back to digit symbols. You can place this block after a amplitude demodulation block. The input of this block is an analog signal in the range [-1, 1]. The demodulation decides the closest integer fitting in [0,M-1] range. When the input symbol interval is a two-elements vector, the second element is offset. The default offset value is 0.')
set_param([sys,'/','MASK demap: MF1'],...
		'Mask Entries','2\/[T, 0.9*T]\/')


%     Finished composite block 'MASK demap: MF1'.

set_param([sys,'/','MASK demap: MF1'],...
		'position',[520,428,600,472])


%     Subsystem  ['Eye-diagram',13,'Without Filter'].

new_system([sys,'/',['Eye-diagram',13,'Without Filter']])
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],'Location',[165,242,460,428])

add_block('built-in/S-Function',[sys,'/',['Eye-diagram',13,'Without Filter/Plot1']])
set_param([sys,'/',['Eye-diagram',13,'Without Filter/Plot1']],...
		'function name','eyediasi',...
		'parameters','time_range, boundary, kept_length, eye_line, scatter_line, two_d_line',...
		'position',[130,70,200,110])

add_block('built-in/Mux',[sys,'/',['Eye-diagram',13,'Without Filter/Mux']])
set_param([sys,'/',['Eye-diagram',13,'Without Filter/Mux']],...
		'inputs','2',...
		'position',[65,70,100,105])

add_block('built-in/Inport',[sys,'/',['Eye-diagram',13,'Without Filter/in_2']])
set_param([sys,'/',['Eye-diagram',13,'Without Filter/in_2']],...
		'Port','2',...
		'position',[20,115,40,135])

add_block('built-in/Inport',[sys,'/',['Eye-diagram',13,'Without Filter/in_1']])
set_param([sys,'/',['Eye-diagram',13,'Without Filter/in_1']],...
		'position',[15,55,35,75])
add_line([sys,'/',['Eye-diagram',13,'Without Filter']],[105,90;125,90])
add_line([sys,'/',['Eye-diagram',13,'Without Filter']],[45,125;50,125;60,95])
add_line([sys,'/',['Eye-diagram',13,'Without Filter']],[40,65;45,65;45,80;60,80])
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);',...
		'Mask Type','Eye-diagram/scatter plot')
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'Mask Dialogue','Produce eye-pattern diagram/scatter\nplot/x-y plot with the rising edge of the second input as the decision line.|Eye-pattern plot time frame:|Lower and upper bound of in-coming signal (1x2 vector):|Number of saved traces:|Line-type for eye-pattern diagram (0 for no plot):|Line-type for scatter plot (0 for no plot):|Line-type for x-y plot (0 for no plot):')
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'Mask Translate','time_range=@1;boundary=@2;kept_length=@3;eye_line=@4;scatter_line=@5;two_d_line=@6;[x,y]=srcsicon(10);[v,w]=trigicon(0,25,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'Mask Help','This plot opens one, two, or three plots by assigning the line type parameters. The scatter plot point is selected by the rising edge of a trigger signal. A decision line is drawn at the rising edge of the trigger signal.')
set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'Mask Entries','2*T\/[-2,2]\/50\/''r-/g--/b-.''\/0\/0\/')


%     Finished composite block ['Eye-diagram',13,'Without Filter'].

set_param([sys,'/',['Eye-diagram',13,'Without Filter']],...
		'position',[610,538,690,582])
add_line(sys,[120,230;165,230])
add_line(sys,[255,230;280,230])
add_line(sys,[375,230;405,230])
add_line(sys,[740,170;790,170])
add_line(sys,[120,250;135,250;135,410;680,410])
add_line(sys,[750,235;825,245])
add_line(sys,[255,230;265,230;265,160;700,160])
add_line(sys,[120,230;135,230;135,190;615,180;825,225])
add_line(sys,[495,230;510,230])
add_line(sys,[560,230;570,230;570,220;595,220])
add_line(sys,[580,275;585,275;595,230])
add_line(sys,[625,225;635,225;635,235;660,235])
add_line(sys,[625,225;635,225;635,390;680,390])
add_line(sys,[625,225;655,225;655,175;700,175])
add_line(sys,[255,230;265,230;265,95;700,95])
add_line(sys,[495,230;500,230;500,110;700,110])
add_line(sys,[740,105;785,105])
add_line(sys,[495,230;500,230;500,450;515,450])
add_line(sys,[605,450;640,450;640,505;685,505])
add_line(sys,[120,230;135,230;135,485;685,485])
add_line(sys,[120,250;135,250;135,570;605,570])
add_line(sys,[495,230;500,230;500,550;605,550])

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
