⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tstqa2cd.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 3 页
字号:
		'inputs','2',...
		'position',[65,46,100,79])

add_block('built-in/S-Function',[sys,'/','Error rate1/S-function'])
set_param([sys,'/','Error rate1/S-function'],...
		'function name','sbiterr',...
		'parameters','num_lin, K, TDelay, Sample',...
		'position',[130,52,195,78])
add_line([sys,'/','Error rate1'],[40,70;60,70])
add_line([sys,'/','Error rate1'],[40,55;60,55])
add_line([sys,'/','Error rate1'],[105,65;125,65])
set_param([sys,'/','Error rate1'],...
		'Mask Display','Error\nmeter',...
		'Mask Type','Symbol/bit error counter')
set_param([sys,'/','Error rate1'],...
		'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 port inputted signal.|Bit per symbol:|Number of digits on display:|Delay between input (1st port) and output (2nd port):|Sampling time (sec):')
set_param([sys,'/','Error rate1'],...
		'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','Error rate1'],...
		'Mask Help','The signal from the first port must be a scalar. The second input port can be a vector with a same-time delay to the input signal. The comparison happens only at the sampling point.')
set_param([sys,'/','Error rate1'],...
		'Mask Entries','6\/20\/td\/td\/')


%     Finished composite block 'Error rate1'.

set_param([sys,'/','Error rate1'],...
		'hide name',0,...
		'position',[575,28,655,72])


%     Subsystem  ['Sampled read',13,'from wksp'].

new_system([sys,'/',['Sampled read',13,'from wksp']])
set_param([sys,'/',['Sampled read',13,'from wksp']],'Location',[355,528,737,675])

add_block('built-in/S-Function',[sys,'/',['Sampled read',13,'from wksp/Message source']])
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
		'BackGround',5,...
		'function name','trigwksp',...
		'parameters','var,thd,cyclFlag,ini',...
		'Mask Display','Triggered\nread',...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read',13,'from wksp/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',13,'from wksp/Message source']],...
		'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;')
set_param([sys,'/',['Sampled read',13,'from wksp/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.',...
		'Mask Entries','var\/.1\/cyc\/ini\/')
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
		'position',[180,53,255,97])

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


%     Subsystem  ['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1'].

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

add_block('built-in/Outport',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']],...
		'position',[160,35,180,55])

add_block('built-in/S-Function',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']],...
		'function name','homopuls',...
		'parameters','samp_time, out_divid, offset',...
		'position',[40,31,105,59])
add_line([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
		'Mask Display','Vector\nPulse',...
		'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read',13,'from wksp/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',13,'from wksp/Pulses deivide',13,'same sample time1']],...
		'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read',13,'from wksp/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',13,'from wksp/Pulses deivide',13,'same sample time1']],...
		'Mask Entries','ts\/1\/off\/')


%     Finished composite block ['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1'].

set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
		'position',[50,56,110,94])
add_line([sys,'/',['Sampled read',13,'from wksp']],[115,75;175,75])
add_line([sys,'/',['Sampled read',13,'from wksp']],[260,75;290,75])
set_param([sys,'/',['Sampled read',13,'from wksp']],...
		'Mask Display','plot(0,0,100,100,x,y);Rd wksp',...
		'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
		'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',13,'from wksp']],...
		'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);')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
		'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 reached 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.')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
		'Mask Entries','randint(300,1,M)\/td\/1\/0\/')


%     Finished composite block ['Sampled read',13,'from wksp'].

set_param([sys,'/',['Sampled read',13,'from wksp']],...
		'hide name',0,...
		'position',[15,38,90,82])

add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
		'hide name',0,...
		'inputs','2',...
		'position',[455,93,490,137])


%     Subsystem  ['Pulses divide',13,'same sample time'].

new_system([sys,'/',['Pulses divide',13,'same sample time']])
set_param([sys,'/',['Pulses divide',13,'same sample time']],'Location',[55,192,283,286])

add_block('built-in/S-Function',[sys,'/',['Pulses divide',13,'same sample time/S-function1']])
set_param([sys,'/',['Pulses divide',13,'same sample time/S-function1']],...
		'function name','homopuls',...
		'parameters','samp_time, out_divid, offset',...
		'position',[40,31,105,59])

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


%     Finished composite block ['Pulses divide',13,'same sample time'].

set_param([sys,'/',['Pulses divide',13,'same sample time']],...
		'hide name',0,...
		'position',[330,123,410,167])


%     Subsystem  ['Eye-diagram',13,'scatter plot'].

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

add_block('built-in/Inport',[sys,'/',['Eye-diagram',13,'scatter plot/in_1']])
set_param([sys,'/',['Eye-diagram',13,'scatter plot/in_1']],...
		'position',[15,55,35,75])

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

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

add_block('built-in/S-Function',[sys,'/',['Eye-diagram',13,'scatter plot/Plot1']])
set_param([sys,'/',['Eye-diagram',13,'scatter plot/Plot1']],...
		'function name','eyediasi',...
		'parameters','time_range, boundary, kept_length, eye_line, scatter_line, two_d_line',...
		'position',[130,70,200,110])
add_line([sys,'/',['Eye-diagram',13,'scatter plot']],[40,65;45,65;45,80;60,80])
add_line([sys,'/',['Eye-diagram',13,'scatter plot']],[45,125;50,125;60,95])
add_line([sys,'/',['Eye-diagram',13,'scatter plot']],[105,90;125,90])
set_param([sys,'/',['Eye-diagram',13,'scatter plot']],...
		'Mask Display','plot(0,0,100,100,x,y,v,w);',...
		'Mask Type','Eye-diagram/scatter plot')
set_param([sys,'/',['Eye-diagram',13,'scatter plot']],...
		'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 such plot):|Line-type for scatter plot (0 for no such plot):|Line-type for x-y plot (0 for no such plot):')
set_param([sys,'/',['Eye-diagram',13,'scatter plot']],...
		'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,'scatter plot']],...
		'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,'scatter plot']],...
		'Mask Entries','td*2\/[-1.2 1.2]\/10\/''r-/g--/b-.''\/''y./g*/bo''\/0\/')


%     Finished composite block ['Eye-diagram',13,'scatter plot'].

set_param([sys,'/',['Eye-diagram',13,'scatter plot']],...
		'hide name',0,...
		'position',[545,113,625,157])


%     Subsystem  ['ASK Mo//Dem',13,'demo1'].

new_system([sys,'/',['ASK Mo//Dem',13,'demo1']])
set_param([sys,'/',['ASK Mo//Dem',13,'demo1']],'Location',[175,552,335,697])
set_param([sys,'/',['ASK Mo//Dem',13,'demo1']],...
		'Mask Display','View\nconstellation',...
		'Mask Dialogue','eval(''modmap(''''qask'''',M)'')')


%     Finished composite block ['ASK Mo//Dem',13,'demo1'].

set_param([sys,'/',['ASK Mo//Dem',13,'demo1']],...
		'BackGround',7,...
		'hide name',0,...
		'position',[75,123,155,167])
add_line(sys,[95,60;115,60])
add_line(sys,[105,60;105,15;540,15;540,40;570,40])
add_line(sys,[540,60;570,60])
add_line(sys,[495,115;515,115;515,125;540,125])
add_line(sys,[415,145;540,145])
add_line(sys,[315,60;335,60])
add_line(sys,[205,70;225,70])
add_line(sys,[205,50;225,50])
add_line(sys,[425,70;450,70])
add_line(sys,[425,50;450,50])
add_line(sys,[440,70;450,105])
add_line(sys,[425,50;435,50;435,125;450,125])

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -