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

📄 testamc2.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 4 页
字号:
function [ret,x0,str,ts,xts]=testamc2(t,x,u,flag);
%TESTAMC2	is the M-file description of the SIMULINK system named TESTAMC2.
%	The block-diagram can be displayed by typing: TESTAMC2.
%
%	SYS=TESTAMC2(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 TESTAMC2 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 TESTAMC2 with a FLAG of zero:
%	[SIZES]=TESTAMC2([],[],[],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',[376,354,883,596])
     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.01')
set_param(sys,'Max step size', '0.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'Load callback','ts=.01;[num,den]=butter(2,100/pi/2*ts);');

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'hide name',0,...
		'inputs','3',...
		'position',[385,55,420,105])


%     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 ''/'':|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','4\/-1.5\/1.5\/''y-/g--/r-/m:/w-/r:/b+''\/ts\/')


%     Finished composite block 'Graph'.

set_param([sys,'/','Graph'],...
		'hide name',0,...
		'position',[450,61,480,99])


%     Subsystem  ['ADM with carrier',13,'passband'].

new_system([sys,'/',['ADM with carrier',13,'passband']])
set_param([sys,'/',['ADM with carrier',13,'passband']],'Location',[67,574,402,724])

add_block('built-in/Inport',[sys,'/',['ADM with carrier',13,'passband/in_1']])
set_param([sys,'/',['ADM with carrier',13,'passband/in_1']],...
		'position',[40,25,60,45])

add_block('built-in/Sum',[sys,'/',['ADM with carrier',13,'passband/Sum']])
set_param([sys,'/',['ADM with carrier',13,'passband/Sum']],...
		'inputs','+-',...
		'position',[240,30,260,50])

add_block('built-in/Outport',[sys,'/',['ADM with carrier',13,'passband/out_1']])
set_param([sys,'/',['ADM with carrier',13,'passband/out_1']],...
		'position',[290,30,310,50])

add_block('built-in/Constant',[sys,'/',['ADM with carrier',13,'passband/Constant']])
set_param([sys,'/',['ADM with carrier',13,'passband/Constant']],...
		'Value','Offset',...
		'position',[90,95,130,115])


%     Subsystem  ['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas'].

new_system([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas']],'Location',[79,73,846,354])


%     Subsystem  ['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator'].

new_system([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],'Location',[40,403,515,507])

add_block('built-in/Outport',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/out_1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/out_1']],...
		'position',[445,30,465,50])

add_block('built-in/Unit Delay',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Unit Delay']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Unit Delay']],...
		'Sample time','ts',...
		'x0','init',...
		'position',[345,30,395,50])

add_block('built-in/Sum',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Sum']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Sum']],...
		'position',[195,30,215,50])

add_block('built-in/Fcn',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/module']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/module']],...
		'Expr','rem(u[1],modu)',...
		'position',[235,29,325,51])

add_block('built-in/Inport',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/in_1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/in_1']],...
		'position',[15,25,35,45])

add_block('built-in/Discrete Transfer Fcn',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Dis. Transfer Fcn']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator/Dis. Transfer Fcn']],...
		'Numerator','ts(1)',...
		'Denominator','1',...
		'Sample time','ts',...
		'position',[90,17,135,53])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[400,40;410,40;410,90;175,90;175,45;190,45])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[410,40;440,40])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[330,40;340,40])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[220,40;230,40])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[40,35;85,35])
add_line([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],[140,35;190,35])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'Mask Display','discrete\nmod-int',...
		'Mask Type','Module Integrator')
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'Mask Dialogue','Module the given number when state exceed limit|Module bound:|Initial value:|Sample time:')
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'Mask Translate','init=@2; modu=@1;ts=@3;')
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'Mask Help','The absolute value of this integrator will not exceed the specified module bound. The state value is set to be zero when the module bound is reached. This block can only be used for scale value calculation.')
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'Mask Entries','1\/0\/ts\/')


%     Finished composite block ['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator'].

set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Dis module',13,'integrator']],...
		'orientation',2,...
		'position',[365,105,425,145])

add_block('built-in/Constant',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Carrier',13,'frequency']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Carrier',13,'frequency']],...
		'orientation',2,...
		'Value','Fc',...
		'position',[510,165,530,185])

add_block('built-in/Product',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product1']],...
		'orientation',2,...
		'position',[610,110,640,130])

add_block('built-in/Filter',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Filter2']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Filter2']],...
		'orientation',2,...
		'Numerator','num',...
		'Denominator','den',...
		'Sample time','ts',...
		'position',[535,100,595,140])

add_block('built-in/Sum',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Sum']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Sum']],...
		'orientation',2,...
		'position',[440,115,460,135])

add_block('built-in/Gain',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Gain1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Gain1']],...
		'orientation',2,...
		'Gain','pi2',...
		'position',[310,110,340,140])

add_block('built-in/Constant',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Carrier',13,'frequency1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Carrier',13,'frequency1']],...
		'orientation',2,...
		'Value','Ph',...
		'position',[320,175,340,195])

add_block('built-in/Sum',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Sum1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Sum1']],...
		'orientation',2,...
		'position',[265,120,285,140])

add_block('built-in/Product',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product2']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product2']],...
		'position',[125,215,150,235])

add_block('built-in/Fcn',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/sin1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/sin1']],...
		'orientation',2,...
		'Expr','-2*sin(u[1])',...
		'position',[115,167,220,193])

add_block('built-in/Product',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Product']],...
		'position',[125,50,150,70])

add_block('built-in/Inport',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/in_1']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/in_1']],...
		'position',[45,45,65,65])

add_block('built-in/Note',[sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Ref: Hambley: An Intro to Comm. Systems. pp69']])
set_param([sys,'/',['ADM with carrier',13,'passband/DSB-SC-ADM',13,'by-Costas/Ref: Hambley: An Intro to Comm. Systems. pp69']],...
		'position',[260,350,265,355])

⌨️ 快捷键说明

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