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

📄 tstap2cd.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
set_param([sys,'/',['MPSK demod',13,'correlation/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,'correlation/Scheduled',13,'reset-int1']],...
		'Mask Entries','td\/ts\/Inf\/',...
		'position',[440,49,500,91])

add_block('built-in/Product',[sys,'/',['MPSK demod',13,'correlation/Product']])
set_param([sys,'/',['MPSK demod',13,'correlation/Product']],...
		'position',[385,51,410,84])

add_block('built-in/Inport',[sys,'/',['MPSK demod',13,'correlation/in_1']])
set_param([sys,'/',['MPSK demod',13,'correlation/in_1']],...
		'position',[305,100,325,120])

add_block('built-in/S-Function',[sys,'/',['MPSK demod',13,'correlation/Array sin']])
set_param([sys,'/',['MPSK demod',13,'correlation/Array sin']],...
		'function name','arysin',...
		'parameters','''cos''',...
		'position',[295,50,345,70])

add_block('built-in/Constant',[sys,'/',['MPSK demod',13,'correlation/Initial phase']])
set_param([sys,'/',['MPSK demod',13,'correlation/Initial phase']],...
		'Value','Ph',...
		'position',[165,48,185,72])

add_block('built-in/Sum',[sys,'/',['MPSK demod',13,'correlation/Sum1']])
set_param([sys,'/',['MPSK demod',13,'correlation/Sum1']],...
		'inputs','+++',...
		'position',[240,40,265,80])

add_block('built-in/Sum',[sys,'/',['MPSK demod',13,'correlation/Sum2']])
set_param([sys,'/',['MPSK demod',13,'correlation/Sum2']],...
		'inputs','+-',...
		'position',[185,90,210,125])

add_block('built-in/Clock',[sys,'/',['MPSK demod',13,'correlation/Clock']])
set_param([sys,'/',['MPSK demod',13,'correlation/Clock']],...
		'position',[15,90,35,110])

add_block('built-in/Zero-Order Hold',[sys,'/',['MPSK demod',13,'correlation/Zero-Order',13,'Hold']])
set_param([sys,'/',['MPSK demod',13,'correlation/Zero-Order',13,'Hold']],...
		'Sample time','td',...
		'position',[125,119,160,151])

add_block('built-in/Gain',[sys,'/',['MPSK demod',13,'correlation/Gain']])
set_param([sys,'/',['MPSK demod',13,'correlation/Gain']],...
		'Gain','Fc',...
		'position',[65,85,105,115])
add_line([sys,'/',['MPSK demod',13,'correlation']],[505,70;520,70])
add_line([sys,'/',['MPSK demod',13,'correlation']],[415,70;435,70])
add_line([sys,'/',['MPSK demod',13,'correlation']],[270,60;290,60])
add_line([sys,'/',['MPSK demod',13,'correlation']],[140,25;225,25;235,45])
add_line([sys,'/',['MPSK demod',13,'correlation']],[190,60;235,60])
add_line([sys,'/',['MPSK demod',13,'correlation']],[40,100;60,100])
add_line([sys,'/',['MPSK demod',13,'correlation']],[215,110;225,110;235,75])
add_line([sys,'/',['MPSK demod',13,'correlation']],[110,100;180,100])
add_line([sys,'/',['MPSK demod',13,'correlation']],[110,100;120,135])
add_line([sys,'/',['MPSK demod',13,'correlation']],[165,135;165,115;180,115])
add_line([sys,'/',['MPSK demod',13,'correlation']],[350,60;380,60])
add_line([sys,'/',['MPSK demod',13,'correlation']],[330,110;360,110;360,75;380,75])
set_param([sys,'/',['MPSK demod',13,'correlation']],...
		'Mask Display','MPSK\ndm corr',...
		'Mask Type','MPSK Demodulation')
set_param([sys,'/',['MPSK demod',13,'correlation']],...
		'Mask Dialogue','Correlation calculation for M-ary phase shift keying demodulation.|M-ary number (integer in range [0, M-1]):|Symbol interval (second):|Carrier frequency (Hz):|Initial phase (rad):|Sample time (second):')
set_param([sys,'/',['MPSK demod',13,'correlation']],...
		'Mask Translate','pi2=2*pi;N=@1;sft=[0:N-1]*pi2/N; td=@2;Fc=@3*pi2;Ph=@4;ts=@5;')
set_param([sys,'/',['MPSK demod',13,'correlation']],...
		'Mask Help','This block calculates the correlation value for MPSK demodulation. The initial phase should match those in the modulation.',...
		'Mask Entries','M\/td\/Fc\/0\/ts\/')


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

set_param([sys,'/',['MPSK demod',13,'correlation']],...
		'position',[345,90,420,130])


%     Subsystem  'Min//Max Index'.

new_system([sys,'/','Min//Max Index'])
set_param([sys,'/','Min//Max Index'],'Location',[36,467,390,564])

add_block('built-in/Inport',[sys,'/','Min//Max Index/in_1'])
set_param([sys,'/','Min//Max Index/in_1'],...
		'position',[65,20,85,40])

add_block('built-in/Zero-Order Hold',[sys,'/',['Min//Max Index/Zero-Order',13,'Hold']])
set_param([sys,'/',['Min//Max Index/Zero-Order',13,'Hold']],...
		'Sample time','td',...
		'position',[125,14,160,46])

add_block('built-in/S-Function',[sys,'/','Min//Max Index/Maximum'])
set_param([sys,'/','Min//Max Index/Maximum'],...
		'function name','arymimai',...
		'parameters','mima',...
		'position',[195,20,275,40])

add_block('built-in/Outport',[sys,'/','Min//Max Index/out_1'])
set_param([sys,'/','Min//Max Index/out_1'],...
		'position',[305,20,325,40])
add_line([sys,'/','Min//Max Index'],[165,30;190,30])
add_line([sys,'/','Min//Max Index'],[280,30;300,30])
add_line([sys,'/','Min//Max Index'],[90,30;120,30])
set_param([sys,'/','Min//Max Index'],...
		'Mask Display','Min/Max\ndecode',...
		'Mask Type','Maximum/Minimum Index.')
set_param([sys,'/','Min//Max Index'],...
		'Mask Dialogue','Choose the maximum or minimum index of inputing element. The output are [0, N-1], where N is input vector length.|Symbol interval (second):|''max'' or ''min'':')
set_param([sys,'/','Min//Max Index'],...
		'Mask Translate','td=@1;mima=@2;',...
		'Mask Help','This block outputs the index of the maximum/minmum element in the input vector.',...
		'Mask Entries','td\/''max''\/')


%     Finished composite block 'Min//Max Index'.

set_param([sys,'/','Min//Max Index'],...
		'position',[455,90,530,130])

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'inputs','2',...
		'position',[575,62,610,113])


%     Subsystem  'Graph'.

new_system([sys,'/','Graph'])
set_param([sys,'/','Graph'],'Location',[0,59,274,252])

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

add_block('built-in/S-Function',[sys,'/',['Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Graph/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,'/','Graph'],[90,65;125,65])
set_param([sys,'/','Graph'],...
		'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,'/','Graph'],...
		'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 ''/'':|Sample time:')
set_param([sys,'/','Graph'],...
		'Mask Translate','color = @4; ax = [0, @1, @2, @3]; dt = @5;')
set_param([sys,'/','Graph'],...
		'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,'/','Graph'],...
		'Mask Entries','20*td\/-1\/M\/''y-/g--/r-/m:/w-/r:/b-''\/td\/')


%     Finished composite block 'Graph'.

set_param([sys,'/','Graph'],...
		'position',[640,71,670,109])


%     Subsystem  'Sampled read'.

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


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

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

add_block('built-in/S-Function',[sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read/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/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/Outport']],...
		'position',[160,35,180,55])
add_line([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'Mask Display','Vector\nPulse',...
		'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read/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/Pulses deivide',13,'same sample time1']],...
		'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read/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/Pulses deivide',13,'same sample time1']],...
		'Mask Entries','ts\/1\/off\/')


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

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

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

add_block('built-in/S-Function',[sys,'/','Sampled read/Message source'])
set_param([sys,'/','Sampled read/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/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/Message source'],...
		'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;',...
		'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/Message source'],...
		'Mask Entries','var\/.1\/cyc\/ini\/',...
		'position',[180,53,255,97])
add_line([sys,'/','Sampled read'],[260,75;290,75])
add_line([sys,'/','Sampled read'],[115,75;175,75])
set_param([sys,'/','Sampled read'],...
		'Mask Display','Sampled\nread\nvariable',...
		'Mask Type','Read from a variable at given sample time.')
set_param([sys,'/','Sampled read'],...
		'Mask Dialogue','Read from a workspace variable at a given interval:|Variable (column_number=block_output_length):|Output symbol interval:|Cyclic read (1) or amend zero (0):|Initial output:')
set_param([sys,'/','Sampled read'],...
		'Mask Translate','var=@1;td=@2;ts=td(1);if (length(td)>=2),off=td(2);else off=0;end;cyc=@3;ini=@4;')
set_param([sys,'/','Sampled read'],...
		'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 row, the block will cyclically output from the first row of the the variable or output zero based on the cyclic read entree.')
set_param([sys,'/','Sampled read'],...
		'Mask Entries','rem([0:100]'',M)\/td\/1\/2\/')


%     Finished composite block 'Sampled read'.

set_param([sys,'/','Sampled read'],...
		'BackGround',5,...
		'position',[25,88,100,132])
add_line(sys,[615,90;635,90])
add_line(sys,[105,110;120,110])
add_line(sys,[110,110;110,45;280,45])
add_line(sys,[350,45;550,45;550,75;570,75])
add_line(sys,[200,110;215,110])
add_line(sys,[300,110;340,110])
add_line(sys,[535,110;555,110;555,100;570,100])
add_line(sys,[425,110;450,110])

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