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

📄 tmppk2cd.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
add_block('built-in/Sum',[sys,'/',['MPSK demod',13,'corr baseband/Sum3']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Sum3']],...
		'position',[535,105,555,125])

add_block('built-in/Inport',[sys,'/',['MPSK demod',13,'corr baseband/in_1']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/in_1']],...
		'position',[175,30,195,50])

add_block('built-in/S-Function',[sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']],...
		'function name','schdint',...
		'parameters','td, ts, limit',...
		'Mask Display','Schdld\nreset-int',...
		'Mask Type','Scheduled reset integration.')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']],...
		'Mask Dialogue','Reset the state to be zero(s) at the scheduled reset point.|Scheduled reset time inteval and offset:|Sample time and offset:|Modulo bound:')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']],...
		'Mask Translate','td=@1;ts=@2;limit=@3;')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']],...
		'Mask Help','This block resets the state(s) to be zero(s) at the begining of reset time inteval. The reset inteval can be a two elements vector with the second element being offset.')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int2']],...
		'Mask Entries','td\/ts\/Inf\/',...
		'position',[420,114,480,156])

add_block('built-in/Product',[sys,'/',['MPSK demod',13,'corr baseband/Product3']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Product3']],...
		'position',[355,116,380,149])

add_block('built-in/S-Function',[sys,'/',['MPSK demod',13,'corr baseband/Array sin']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Array sin']],...
		'ForeGround',4,...
		'function name','arysin',...
		'parameters','''sin''',...
		'position',[230,130,280,150])

add_block('built-in/Outport',[sys,'/',['MPSK demod',13,'corr baseband/out_1']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/out_1']],...
		'position',[585,105,605,125])

add_block('built-in/S-Function',[sys,'/',['MPSK demod',13,'corr baseband/Array cos']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Array cos']],...
		'ForeGround',3,...
		'function name','arysin',...
		'parameters','''cos''',...
		'position',[230,85,280,105])

add_block('built-in/Demux',[sys,'/',['MPSK demod',13,'corr baseband/Demux']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Demux']],...
		'ForeGround',2,...
		'outputs','2',...
		'position',[235,20,275,55])

add_block('built-in/Product',[sys,'/',['MPSK demod',13,'corr baseband/Product']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Product']],...
		'position',[355,21,380,54])

add_block('built-in/S-Function',[sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']],...
		'function name','schdint',...
		'parameters','td, ts, limit',...
		'Mask Display','Schdld\nreset-int',...
		'Mask Type','Scheduled reset integration.')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']],...
		'Mask Dialogue','Reset the state to be zero(s) at the scheduled reset point.|Scheduled reset time inteval and offset:|Sample time and offset:|Modulo bound:')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']],...
		'Mask Translate','td=@1;ts=@2;limit=@3;')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']],...
		'Mask Help','This block resets the state(s) to be zero(s) at the begining of reset time inteval. The reset inteval can be a two elements vector with the second element being offset.')
set_param([sys,'/',['MPSK demod',13,'corr baseband/Scheduled',13,'reset-int1']],...
		'Mask Entries','td\/ts\/Inf\/',...
		'position',[420,19,480,61])

add_block('built-in/Sum',[sys,'/',['MPSK demod',13,'corr baseband/Sum1']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Sum1']],...
		'position',[165,75,190,115])

add_block('built-in/Constant',[sys,'/',['MPSK demod',13,'corr baseband/Shift key']])
set_param([sys,'/',['MPSK demod',13,'corr baseband/Shift key']],...
		'Value','sft',...
		'position',[40,63,60,87])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[65,75;95,75;95,85;160,85])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[125,105;160,105])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[195,95;225,95])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[205,95;205,140;225,140])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[280,30;350,30])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[285,95;320,95;320,45;350,45])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[560,115;580,115])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[485,135;510,135;510,120;530,120])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[485,40;510,40;510,110;530,110])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[385,40;415,40])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[385,135;415,135])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[285,140;350,140])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[280,45;310,45;310,125;350,125])
add_line([sys,'/',['MPSK demod',13,'corr baseband']],[200,40;230,40])
set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'Mask Display','plot(0,0,100,100,u,v);  MPSK corr',...
		'Mask Type','Baseband MPSK correlationA')
set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'Mask Dialogue','Compute Baseband MPSK correlation. Take\nMPSK CE modulated signal. Output a vector of correlation result.|M-ary number (integer in range [0, M-1]):|Symbol interval and offset (sec):|Initial phase (rad):|Sample time (sec):')
set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'Mask Translate','pi2=2*pi;N=@1;sft=[0:N-1]*pi2/N;td=@2;Ph=@3;ts=@4;[u,v]=cmplxicn(0,50,get_param(gcb,''orientation''));')
set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'Mask Help','This block calculates the correlation value of the input signal with a vector of sinusoidal signals. These sinusoidal signals have their phase shift the same as that of PM modulated signal of possible resulting digits. The output is an M length vector. M is the M-ary number. The MPSK demodulation result is the index of the largest output, using the Min/max demap block. The input of this block is complex signal.')
set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'Mask Entries','M\/td\/0\/ts\/')


%     Finished composite block ['MPSK demod',13,'corr baseband'].

set_param([sys,'/',['MPSK demod',13,'corr baseband']],...
		'hide name',0,...
		'position',[340,63,420,107])


%     Subsystem  ['PM',13,'baseband'].

new_system([sys,'/',['PM',13,'baseband']])
set_param([sys,'/',['PM',13,'baseband']],'Location',[320,489,688,666])

add_block('built-in/Inport',[sys,'/',['PM',13,'baseband/in_1']])
set_param([sys,'/',['PM',13,'baseband/in_1']],...
		'position',[35,50,55,70])

add_block('built-in/Fcn',[sys,'/',['PM',13,'baseband/cos']])
set_param([sys,'/',['PM',13,'baseband/cos']],...
		'Expr','cos(u)',...
		'position',[155,46,210,74])

add_block('built-in/Fcn',[sys,'/',['PM',13,'baseband/sin']])
set_param([sys,'/',['PM',13,'baseband/sin']],...
		'Expr','sin(u)',...
		'position',[155,106,210,134])

add_block('built-in/Outport',[sys,'/',['PM',13,'baseband/out_1']])
set_param([sys,'/',['PM',13,'baseband/out_1']],...
		'position',[315,60,335,80])

add_block('built-in/Mux',[sys,'/',['PM',13,'baseband/Mux']])
set_param([sys,'/',['PM',13,'baseband/Mux']],...
		'inputs','2',...
		'position',[250,51,285,84])
add_line([sys,'/',['PM',13,'baseband']],[60,60;150,60])
add_line([sys,'/',['PM',13,'baseband']],[130,60;130,120;150,120])
add_line([sys,'/',['PM',13,'baseband']],[215,120;230,120;230,75;245,75])
add_line([sys,'/',['PM',13,'baseband']],[290,70;310,70])
add_line([sys,'/',['PM',13,'baseband']],[215,60;245,60])
set_param([sys,'/',['PM',13,'baseband']],...
		'Mask Display','plot(0,0,100,100,x,y,u,v);PM',...
		'Mask Type','PM CE',...
		'Mask Dialogue','Output the complex envelope of a PM\nmodulated signal.|Initial phase (rad):')
set_param([sys,'/',['PM',13,'baseband']],...
		'Mask Translate','Ph=@1;pi2=2*pi;[x,y]=moduicon(3);[u,v]=cmplxicn(1,50,get_param(gcb,''orientation''));')
set_param([sys,'/',['PM',13,'baseband']],...
		'Mask Help','This block outputs the complex envelope of the phase modulated signal. The output of this block is a complex signal.',...
		'Mask Entries','0\/')


%     Finished composite block ['PM',13,'baseband'].

set_param([sys,'/',['PM',13,'baseband']],...
		'hide name',0,...
		'position',[235,63,315,107])


%     Subsystem  'Error rate1'.

new_system([sys,'/','Error rate1'])
set_param([sys,'/','Error rate1'],'Location',[255,368,509,510])

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_block('built-in/Mux',[sys,'/','Error rate1/Mux'])
set_param([sys,'/','Error rate1/Mux'],...
		'inputs','2',...
		'position',[65,46,100,79])

add_block('built-in/Inport',[sys,'/','Error rate1/in_1'])
set_param([sys,'/','Error rate1/in_1'],...
		'position',[15,45,35,65])

add_block('built-in/Inport',[sys,'/','Error rate1/in_2'])
set_param([sys,'/','Error rate1/in_2'],...
		'Port','2',...
		'position',[15,60,35,80])
add_line([sys,'/','Error rate1'],[105,65;125,65])
add_line([sys,'/','Error rate1'],[40,55;60,55])
add_line([sys,'/','Error rate1'],[40,70;60,70])
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','3\/20\/td\/td\/')


%     Finished composite block 'Error rate1'.

set_param([sys,'/','Error rate1'],...
		'hide name',0,...
		'position',[560,53,640,97])
add_line(sys,[425,85;445,85])
add_line(sys,[320,85;335,85])
add_line(sys,[215,85;230,85])
add_line(sys,[535,85;555,85])
add_line(sys,[100,85;125,85])
add_line(sys,[110,85;110,40;540,40;540,65;555,65])

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 + -