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

📄 tstdpcms.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
function [ret,x0,str,ts,xts]=tstdpcms(t,x,u,flag);
%TSTDPCMS	is the M-file description of the SIMULINK system named TSTDPCMS.
%	The block-diagram can be displayed by typing: TSTDPCMS.
%
%	SYS=TSTDPCMS(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 TSTDPCMS 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 TSTDPCMS with a FLAG of zero:
%	[SIZES]=TSTDPCMS([],[],[],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',[75,397,631,656])
     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', '0.0001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'Load callback','x=sin(0:.1:40);[p_trans,codebook,partition]=dpcmopt(x,1,8);');

add_block('built-in/Signal Generator',[sys,'/',['Signal',13,'generator']])
set_param([sys,'/',['Signal',13,'generator']],...
		'BackGround',5,...
		'hide name',0,...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','1.000000',...
		'Freq Range','5.000000',...
		'Wave','Sin',...
		'Units','Rads')
set_param([sys,'/',['Signal',13,'generator']],...
		'position',[30,13,75,47])

add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
		'hide name',0,...
		'inputs','2',...
		'position',[420,20,455,55])


%     Subsystem  'Graph'.

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

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_block('built-in/Inport',[sys,'/','Graph/x'])
set_param([sys,'/','Graph/x'],...
		'position',[65,55,85,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 ''/'':')
set_param([sys,'/','Graph'],...
		'Mask Translate','color = @4; ax = [0, @1, @2, @3]; dt = -1;')
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','10\/-1.2\/1.2\/''y-/r--/y*/g*/yo/go/b+''\/')


%     Finished composite block 'Graph'.

set_param([sys,'/','Graph'],...
		'hide name',0,...
		'position',[490,21,520,59])


%     Subsystem  ['DPCM',13,'decode'].

new_system([sys,'/',['DPCM',13,'decode']])
set_param([sys,'/',['DPCM',13,'decode']],'Location',[32,515,384,677])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'decode/out_2']])
set_param([sys,'/',['DPCM',13,'decode/out_2']],...
		'Port','2',...
		'position',[235,10,255,30])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'decode/out_1']])
set_param([sys,'/',['DPCM',13,'decode/out_1']],...
		'position',[315,45,335,65])

add_block('built-in/Filter',[sys,'/',['DPCM',13,'decode/Filter']])
set_param([sys,'/',['DPCM',13,'decode/Filter']],...
		'orientation',2,...
		'Numerator','num',...
		'Denominator','den',...
		'Sample time','sample_time',...
		'position',[200,90,260,130])

add_block('built-in/Sum',[sys,'/',['DPCM',13,'decode/Sum1']])
set_param([sys,'/',['DPCM',13,'decode/Sum1']],...
		'position',[185,45,205,65])


%     Subsystem  ['DPCM',13,'decode/Quantizer',13,'decode'].

new_system([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']])
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],'Location',[596,274,888,411])

add_block('built-in/S-Function',[sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/Index lookup',13,'table']])
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/Index lookup',13,'table']],...
		'function name','indxtabl',...
		'parameters','codebook',...
		'Mask Display','Index\nLookup tb',...
		'Mask Type','No-intepret Lookup table')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/Index lookup',13,'table']],...
		'Mask Dialogue','Output one of the values in the look-up table.|Codebook:',...
		'Mask Translate','codebook=@1;')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/Index lookup',13,'table']],...
		'Mask Help','When codebook is a matrix, the block input can only be a scalar. The block output the row with the column index provided in the input. When codebook is a vector, the block output the same length as the input vector. The output is one of the values in codebook with the index provided by the input.')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/Index lookup',13,'table']],...
		'Mask Entries','codebook\/',...
		'position',[105,19,165,61])

add_block('built-in/Outport',[sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/out_1']])
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/out_1']],...
		'position',[225,30,245,50])

add_block('built-in/Inport',[sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/in_1']])
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode/in_1']],...
		'position',[20,30,40,50])
add_line([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],[45,40;100,40])
add_line([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],[170,40;220,40])
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
		'Mask Display','Quantizer\ndecode',...
		'Mask Type','Scalar quantization decode')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
		'Mask Dialogue','Output is one of the elements in codebook. Output vector length is the same as the input length.|Quantization codebook:',...
		'Mask Translate','codebook=@1;')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
		'Mask Help','This block takes the quantized index as input and returns the quantization value. The output vector size the the same as the input vector size. Input 0, 1, ..., N-1 leads to CK(1), CK(2), .. CK(N) ouptut.')
set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
		'Mask Entries','codebook\/')


%     Finished composite block ['DPCM',13,'decode/Quantizer',13,'decode'].

set_param([sys,'/',['DPCM',13,'decode/Quantizer',13,'decode']],...
		'position',[85,30,145,70])

add_block('built-in/Inport',[sys,'/',['DPCM',13,'decode/in_1']])
set_param([sys,'/',['DPCM',13,'decode/in_1']],...
		'position',[30,40,50,60])
add_line([sys,'/',['DPCM',13,'decode']],[150,50;180,50])
add_line([sys,'/',['DPCM',13,'decode']],[160,50;160,20;230,20])
add_line([sys,'/',['DPCM',13,'decode']],[210,55;310,55])
add_line([sys,'/',['DPCM',13,'decode']],[285,55;285,110;265,110])
add_line([sys,'/',['DPCM',13,'decode']],[195,110;165,110;165,60;180,60])
add_line([sys,'/',['DPCM',13,'decode']],[55,50;80,50])
set_param([sys,'/',['DPCM',13,'decode']],...
		'Mask Display','DPCM\ndecode',...
		'Mask Type','DPCM decode')
set_param([sys,'/',['DPCM',13,'decode']],...
		'Mask Dialogue','Input the DPCM coded index. Output\nDPCM decodes to the 1st outport and\nquantization decode to the 2nd outport.|Predictor transfer function numerator:|Predictor transfer function denominator:|Quantization codebook:|Sample time (sec):')

⌨️ 快捷键说明

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