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

📄 com_moce.m

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

add_block('built-in/Note',[sys,'/','Digital Modulation//Demodulation Library'])
set_param([sys,'/','Digital Modulation//Demodulation Library'],...
		'ForeGround',2,...
		'Font Weight','bold',...
		'Font Size',12,...
		'position',[250,0,255,5])


%     Subsystem  ['MFSK mod',13,'baseband'].

new_system([sys,'/',['MFSK mod',13,'baseband']])
set_param([sys,'/',['MFSK mod',13,'baseband']],'Location',[21,547,367,688])

add_block('built-in/Inport',[sys,'/',['MFSK mod',13,'baseband/in_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/in_1']],...
		'position',[15,60,35,80])

add_block('built-in/Outport',[sys,'/',['MFSK mod',13,'baseband/out_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/out_1']],...
		'position',[290,60,310,80])


%     Subsystem  ['MFSK mod',13,'baseband/FM',13,'baseband'].

new_system([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],'Location',[55,571,668,718])

add_block('built-in/S-Function',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']],...
		'function name','schdint',...
		'parameters','td, ts, limit',...
		'Mask Display','Schdld\nreset-int',...
		'Mask Type','Scheduled reset integration.')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']],...
		'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,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']],...
		'Mask Translate','td=@1;ts=@2;limit=@3;')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']],...
		'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,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Scheduled',13,'reset-int']],...
		'Mask Entries','td\/ts\/pi2\/',...
		'position',[155,14,215,56])

add_block('built-in/Gain',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Sensitivity']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Sensitivity']],...
		'Gain','pi2',...
		'position',[80,25,120,55])

add_block('built-in/Outport',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/out_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/out_1']],...
		'position',[550,40,570,60])

add_block('built-in/Mux',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Mux']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Mux']],...
		'inputs','2',...
		'position',[415,31,450,64])

add_block('built-in/Fcn',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/sin']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/sin']],...
		'Expr','sin(u)',...
		'position',[330,86,385,114])

add_block('built-in/Fcn',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/cos']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/cos']],...
		'Expr','cos(u)',...
		'position',[330,26,385,54])

add_block('built-in/Inport',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/in_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/in_1']],...
		'position',[35,25,55,45])

add_block('built-in/Sum',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Sum']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Sum']],...
		'position',[265,30,285,50])

add_block('built-in/Constant',[sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Constant']])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband/Constant']],...
		'Value','Ph',...
		'position',[180,90,205,110])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[125,40;150,35])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[60,35;60,40;75,40])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[390,100;395,100;395,55;410,55])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[455,50;545,50])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[390,40;410,40])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[220,35;260,35])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[210,100;250,100;260,45])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[290,40;325,40])
add_line([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],[300,40;300,100;325,100])
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'Mask Display','plot(0,0,100,100,x,y,u,v);FM',...
		'Mask Type','FM CE')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'Mask Dialogue','Output the complex envelope of the FM signal.|Initial phase (rad):|Sample time (second):|Symbol interval (for digital mod, use Inf for analog mod):')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'Mask Translate','Kc=2*pi;Ph=@1;pi2=2*pi;ts=@2;td=@3;if isinf(td),td=inf;end;[x,y]=moduicon(3);[u,v]=cmplxicn(1,50,get_param(gcb,''orientation''));')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'Mask Help','This block outputs the complex envelope of the frequency modulated signal. The output is a complex signal. This block resets the phase at the very beginning of the symbol interval. For continuous-time simulation, the symbol interval can be set as infinity.')
set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'Mask Entries','Ph\/ts\/td\/')


%     Finished composite block ['MFSK mod',13,'baseband/FM',13,'baseband'].

set_param([sys,'/',['MFSK mod',13,'baseband/FM',13,'baseband']],...
		'ForeGround',4,...
		'position',[185,48,260,92])


%     Subsystem  ['MFSK mod',13,'baseband/MFSK map'].

new_system([sys,'/',['MFSK mod',13,'baseband/MFSK map']])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],'Location',[90,420,407,543])

add_block('built-in/Inport',[sys,'/',['MFSK mod',13,'baseband/MFSK map/in_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map/in_1']],...
		'position',[45,45,65,65])

add_block('built-in/Gain',[sys,'/',['MFSK mod',13,'baseband/MFSK map/Gain']])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map/Gain']],...
		'Gain','Ton',...
		'position',[175,38,225,72])

add_block('built-in/Outport',[sys,'/',['MFSK mod',13,'baseband/MFSK map/out_1']])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map/out_1']],...
		'position',[260,45,280,65])

add_block('built-in/Zero-Order Hold',[sys,'/',['MFSK mod',13,'baseband/MFSK map/Zero-Order',13,'Hold1']])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map/Zero-Order',13,'Hold1']],...
		'Sample time','td',...
		'position',[105,39,140,71])
add_line([sys,'/',['MFSK mod',13,'baseband/MFSK map']],[230,55;255,55])
add_line([sys,'/',['MFSK mod',13,'baseband/MFSK map']],[70,55;100,55])
add_line([sys,'/',['MFSK mod',13,'baseband/MFSK map']],[145,55;170,55])
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'Mask Display','MFSK\nmap',...
		'Mask Type','MFSK map')
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'Mask Dialogue','Map input digital signal to analog tone space for FM modulation. The tone space\nis the frequency distance between two \nconsective digit numbers.|Tone space (Hz):|Input symbol interval and offset (sec):')
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'Mask Translate','Ton=@1;td=@2;')
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'Mask Help','This block maps the input digital signal to the analog signal, which is ready for the FM modulation. The input are integers in the range [0, M-1], where M is the M-ary number. Tone space is the frequency separation between two consective digits for the input signal. After FM, the modulated signal has a frequency in the range of [Fc, Fc+B]. B is the bandwidth of the FSK, B=(M-1) * Tone_space.')
set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'Mask Entries','Ton\/td\/')


%     Finished composite block ['MFSK mod',13,'baseband/MFSK map'].

set_param([sys,'/',['MFSK mod',13,'baseband/MFSK map']],...
		'position',[70,48,150,92])
add_line([sys,'/',['MFSK mod',13,'baseband']],[265,70;285,70])
add_line([sys,'/',['MFSK mod',13,'baseband']],[155,70;180,70])
add_line([sys,'/',['MFSK mod',13,'baseband']],[40,70;65,70])
set_param([sys,'/',['MFSK mod',13,'baseband']],...
		'Mask Display','plot(0,0,100,100,x,y,u,v);MFSK',...
		'Mask Type','Baseband MFSK modulation')
set_param([sys,'/',['MFSK mod',13,'baseband']],...
		'Mask Dialogue','Output the complex envelope of the\nmultiple-frequency shift keying modulation.|Tone space(Hz):|Symbol interval (sec):|Initial phase (rad):|Sample frequency (sec):')
set_param([sys,'/',['MFSK mod',13,'baseband']],...
		'Mask Translate','Ton=@1;td=@2;Ph=@3;ts=@4;if isinf(td),td=inf;end;[x,y]=moduicon(7);[u,v]=cmplxicn(1,50,get_param(gcb,''orientation''));')
set_param([sys,'/',['MFSK mod',13,'baseband']],...
		'Mask Help','This block outputs the complex envelop of MFSK modulated signal. The input signal is integers in the range [0, M-1]. The maximum amplitude of the output is 1. When the symbol interval is a two-element vector, the second element is the offset (default 0). The block takes the input value at the sampling time point.')
set_param([sys,'/',['MFSK mod',13,'baseband']],...
		'Mask Entries','16/.2/5\/.2\/0\/.01\/')


%     Finished composite block ['MFSK mod',13,'baseband'].

⌨️ 快捷键说明

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