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

📄 com_frmt.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 4 页
字号:
function [ret,x0,str,ts,xts]=com_frmt(t,x,u,flag);
%COM_FRMT	is the M-file description of the SIMULINK system named COM_FRMT.
%	The block-diagram can be displayed by typing: COM_FRMT.
%
%	SYS=COM_FRMT(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 COM_FRMT 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 COM_FRMT with a FLAG of zero:
%	[SIZES]=COM_FRMT([],[],[],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',[58,65,461,519])
     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',   '')


%     Subsystem  ['A-law',13,'expander'].

new_system([sys,'/',['A-law',13,'expander']])
set_param([sys,'/',['A-law',13,'expander']],'Location',[22,127,673,410])

add_block('built-in/Constant',[sys,'/',['A-law',13,'expander/Constant']])
set_param([sys,'/',['A-law',13,'expander/Constant']],...
		'ForeGround',3,...
		'Value','VdA',...
		'position',[250,185,295,205])

add_block('built-in/S-Function',[sys,'/',['A-law',13,'expander/Array',13,'function']])
set_param([sys,'/',['A-law',13,'expander/Array',13,'function']],...
		'ForeGround',2,...
		'function name','arysin',...
		'parameters','opr',...
		'Mask Display','Array\nFcn',...
		'Mask Type','Array function')
set_param([sys,'/',['A-law',13,'expander/Array',13,'function']],...
		'Mask Dialogue','Multi-input/multi-output functions, such as sin, cos, tan,exp,asin, acos,ln,log10.|Operation (string):',...
		'Mask Translate','opr=@1;')
set_param([sys,'/',['A-law',13,'expander/Array',13,'function']],...
		'Mask Help','The vector length of the output is the same as the input.',...
		'Mask Entries','''exp''\/',...
		'position',[305,136,350,164])

add_block('built-in/Sum',[sys,'/',['A-law',13,'expander/Sum']])
set_param([sys,'/',['A-law',13,'expander/Sum']],...
		'BackGround',5,...
		'inputs','+-',...
		'position',[260,140,280,160])

add_block('built-in/Constant',[sys,'/',['A-law',13,'expander/Constant4']])
set_param([sys,'/',['A-law',13,'expander/Constant4']],...
		'ForeGround',3,...
		'position',[175,180,200,200])

add_block('built-in/Inport',[sys,'/',['A-law',13,'expander/Inport']])
set_param([sys,'/',['A-law',13,'expander/Inport']],...
		'position',[30,70,50,90])

add_block('built-in/Abs',[sys,'/',['A-law',13,'expander/Abs']])
set_param([sys,'/',['A-law',13,'expander/Abs']],...
		'position',[105,68,135,92])

add_block('built-in/Outport',[sys,'/',['A-law',13,'expander/out_1']])
set_param([sys,'/',['A-law',13,'expander/out_1']],...
		'position',[570,105,590,125])

add_block('built-in/Product',[sys,'/',['A-law',13,'expander/Product1']])
set_param([sys,'/',['A-law',13,'expander/Product1']],...
		'BackGround',7,...
		'position',[510,103,535,127])

add_block('built-in/Relational Operator',[sys,'/',['A-law',13,'expander/Relational',13,'Operator']])
set_param([sys,'/',['A-law',13,'expander/Relational',13,'Operator']],...
		'BackGround',5,...
		'Operator','<=',...
		'position',[330,73,360,102])

add_block('built-in/Constant',[sys,'/',['A-law',13,'expander/Constant1']])
set_param([sys,'/',['A-law',13,'expander/Constant1']],...
		'ForeGround',3,...
		'Value','VdlnA1',...
		'position',[200,84,250,106])

add_block('built-in/Switch',[sys,'/',['A-law',13,'expander/Switch']])
set_param([sys,'/',['A-law',13,'expander/Switch']],...
		'Threshold','.2',...
		'position',[445,74,470,106])

add_block('built-in/Constant',[sys,'/',['A-law',13,'expander/Constant3']])
set_param([sys,'/',['A-law',13,'expander/Constant3']],...
		'ForeGround',3,...
		'Value','lnA1dA',...
		'position',[80,27,125,53])

add_block('built-in/Product',[sys,'/',['A-law',13,'expander/Product2']])
set_param([sys,'/',['A-law',13,'expander/Product2']],...
		'BackGround',7,...
		'position',[265,33,295,57])

add_block('built-in/S-Function',[sys,'/',['A-law',13,'expander/Array',13,'function1']])
set_param([sys,'/',['A-law',13,'expander/Array',13,'function1']],...
		'ForeGround',2,...
		'function name','arysin',...
		'parameters','opr',...
		'Mask Display','Array\nFcn',...
		'Mask Type','Array function')
set_param([sys,'/',['A-law',13,'expander/Array',13,'function1']],...
		'Mask Dialogue','Multi-input/multi-output functions, such as sin, cos, tan,exp,asin, acos,ln,log10.|Operation (string):',...
		'Mask Translate','opr=@1;')
set_param([sys,'/',['A-law',13,'expander/Array',13,'function1']],...
		'Mask Help','The vector length of the output is the same as the input.',...
		'Mask Entries','''sgn''\/',...
		'position',[115,206,160,234])

add_block('built-in/Product',[sys,'/',['A-law',13,'expander/Product']])
set_param([sys,'/',['A-law',13,'expander/Product']],...
		'BackGround',7,...
		'position',[380,143,410,167])

add_block('built-in/Constant',[sys,'/',['A-law',13,'expander/Constant2']])
set_param([sys,'/',['A-law',13,'expander/Constant2']],...
		'ForeGround',3,...
		'Value','lnA1dV',...
		'position',[95,140,145,160])

add_block('built-in/Product',[sys,'/',['A-law',13,'expander/Product3']])
set_param([sys,'/',['A-law',13,'expander/Product3']],...
		'BackGround',7,...
		'position',[185,133,215,157])
add_line([sys,'/',['A-law',13,'expander']],[355,150;375,150])
add_line([sys,'/',['A-law',13,'expander']],[285,150;300,150])
add_line([sys,'/',['A-law',13,'expander']],[220,145;255,145])
add_line([sys,'/',['A-law',13,'expander']],[55,80;100,80])
add_line([sys,'/',['A-law',13,'expander']],[540,115;565,115])
add_line([sys,'/',['A-law',13,'expander']],[70,80;70,220;110,220])
add_line([sys,'/',['A-law',13,'expander']],[165,220;480,220;480,120;505,120])
add_line([sys,'/',['A-law',13,'expander']],[475,90;485,90;485,110;505,110])
add_line([sys,'/',['A-law',13,'expander']],[140,80;325,80])
add_line([sys,'/',['A-law',13,'expander']],[255,95;325,95])
add_line([sys,'/',['A-law',13,'expander']],[365,90;440,90])
add_line([sys,'/',['A-law',13,'expander']],[160,80;160,50;260,50])
add_line([sys,'/',['A-law',13,'expander']],[300,45;400,45;400,80;440,80])
add_line([sys,'/',['A-law',13,'expander']],[130,40;260,40])
add_line([sys,'/',['A-law',13,'expander']],[150,150;180,150])
add_line([sys,'/',['A-law',13,'expander']],[160,80;160,140;180,140])
add_line([sys,'/',['A-law',13,'expander']],[205,190;235,190;235,155;255,155])
add_line([sys,'/',['A-law',13,'expander']],[300,195;365,195;375,160])
add_line([sys,'/',['A-law',13,'expander']],[415,155;420,155;420,100;440,100])
set_param([sys,'/',['A-law',13,'expander']],...
		'Mask Display','A-law\nexpander',...
		'Mask Type','A-law expander',...
		'Mask Dialogue','Inverse computation of A-law compressor.|A value:|Signal peak magnitude:')
set_param([sys,'/',['A-law',13,'expander']],...
		'Mask Translate','A=@1;V=@2;lnA1=log(A)+1;VdlnA1=V/lnA1;lnA1dA=lnA1/A;lnA1dV=lnA1/V;VdA=V/A;')
set_param([sys,'/',['A-law',13,'expander']],...
		'Mask Help','This block reverses the computation with A-law compressor. The prevailing value for A is A=87.6.',...
		'Mask Entries','87.6\/1\/')


%     Finished composite block ['A-law',13,'expander'].

set_param([sys,'/',['A-law',13,'expander']],...
		'position',[165,283,245,327])


%     Subsystem  ['mu-law',13,'expander'].

new_system([sys,'/',['mu-law',13,'expander']])
set_param([sys,'/',['mu-law',13,'expander']],'Location',[29,427,472,583])

add_block('built-in/Product',[sys,'/',['mu-law',13,'expander/Product']])
set_param([sys,'/',['mu-law',13,'expander/Product']],...
		'position',[130,53,160,77])

add_block('built-in/Constant',[sys,'/',['mu-law',13,'expander/Constant1']])
set_param([sys,'/',['mu-law',13,'expander/Constant1']],...
		'Value','ln1mdV',...
		'position',[30,5,80,25])

add_block('built-in/Inport',[sys,'/',['mu-law',13,'expander/Inport']])
set_param([sys,'/',['mu-law',13,'expander/Inport']],...
		'position',[10,60,30,80])

add_block('built-in/Abs',[sys,'/',['mu-law',13,'expander/Abs']])
set_param([sys,'/',['mu-law',13,'expander/Abs']],...
		'position',[65,58,95,82])

add_block('built-in/S-Function',[sys,'/',['mu-law',13,'expander/Array',13,'function1']])
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function1']],...
		'function name','arysin',...
		'parameters','opr',...
		'Mask Display','Array\nFcn',...
		'Mask Type','Array function')
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function1']],...
		'Mask Dialogue','Multi-input/multi-output functions, such as sin, cos, tan,exp,asin, acos,ln,log10.|Operation (string):',...
		'Mask Translate','opr=@1;')
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function1']],...
		'Mask Help','The vector length of the output is the same as the input.',...
		'Mask Entries','''exp''\/',...
		'position',[190,51,235,79])

add_block('built-in/Sum',[sys,'/',['mu-law',13,'expander/Sum']])
set_param([sys,'/',['mu-law',13,'expander/Sum']],...
		'inputs','-+',...
		'position',[275,50,295,70])

add_block('built-in/Constant',[sys,'/',['mu-law',13,'expander/Constant3']])
set_param([sys,'/',['mu-law',13,'expander/Constant3']],...
		'position',[205,10,225,30])

add_block('built-in/S-Function',[sys,'/',['mu-law',13,'expander/Array',13,'function2']])
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function2']],...
		'function name','arysin',...
		'parameters','opr',...
		'Mask Display','Array\nFcn',...
		'Mask Type','Array function')
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function2']],...
		'Mask Dialogue','Multi-input/multi-output functions, such as sin, cos, tan,exp,asin, acos,ln,log10.|Operation (string):',...
		'Mask Translate','opr=@1;')
set_param([sys,'/',['mu-law',13,'expander/Array',13,'function2']],...
		'Mask Help','The vector length of the output is the same as the input.',...
		'Mask Entries','''sgn''\/',...
		'position',[260,96,305,124])

add_block('built-in/Constant',[sys,'/',['mu-law',13,'expander/Constant2']])
set_param([sys,'/',['mu-law',13,'expander/Constant2']],...
		'Value','Vmu',...
		'position',[265,10,315,30])

add_block('built-in/Product',[sys,'/',['mu-law',13,'expander/Product1']])
set_param([sys,'/',['mu-law',13,'expander/Product1']],...
		'inputs','3',...
		'position',[360,45,385,75])

add_block('built-in/Outport',[sys,'/',['mu-law',13,'expander/out_1']])

⌨️ 快捷键说明

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