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

📄 testssba.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 5 页
字号:
function [ret,x0,str,ts,xts]=testssba(t,x,u,flag);
%TESTSSBA	is the M-file description of the SIMULINK system named TESTSSBA.
%	The block-diagram can be displayed by typing: TESTSSBA.
%
%	SYS=TESTSSBA(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 TESTSSBA 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 TESTSSBA with a FLAG of zero:
%	[SIZES]=TESTSSBA([],[],[],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',[370,341,860,670])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '4')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '.1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
		'hide name',0,...
		'inputs','3',...
		'position',[350,7,385,63])


%     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',[435,16,465,54])


%     Subsystem  'USB-AM'.

new_system([sys,'/','USB-AM'])
set_param([sys,'/','USB-AM'],'Location',[76,558,518,713])

add_block('built-in/Gain',[sys,'/','USB-AM/Gain'])
set_param([sys,'/','USB-AM/Gain'],...
		'Gain','k',...
		'position',[185,72,215,98])

add_block('built-in/Filter',[sys,'/','USB-AM/Filter'])
set_param([sys,'/','USB-AM/Filter'],...
		'Numerator','num',...
		'Denominator','den',...
		'Sample time','ts',...
		'position',[95,66,150,104])

add_block('built-in/Inport',[sys,'/','USB-AM/in_1'])
set_param([sys,'/','USB-AM/in_1'],...
		'position',[30,20,50,40])

add_block('built-in/Note',[sys,'/','USB-AM/Ref: Hambley: An Intro to Comm. Systems. pp82'])
set_param([sys,'/','USB-AM/Ref: Hambley: An Intro to Comm. Systems. pp82'],...
		'position',[355,290,360,295])

add_block('built-in/Outport',[sys,'/','USB-AM/out_1'])
set_param([sys,'/','USB-AM/out_1'],...
		'position',[400,55,420,75])


%     Subsystem  'USB-AM/QAM discr-filt'.

new_system([sys,'/','USB-AM/QAM discr-filt'])
set_param([sys,'/','USB-AM/QAM discr-filt'],'Location',[302,478,834,743])

add_block('built-in/Fcn',[sys,'/','USB-AM/QAM discr-filt/Fcn'])
set_param([sys,'/','USB-AM/QAM discr-filt/Fcn'],...
		'Expr','cos(u[1]+Ph)',...
		'position',[230,55,325,85])

add_block('built-in/Fcn',[sys,'/','USB-AM/QAM discr-filt/Fcn1'])
set_param([sys,'/','USB-AM/QAM discr-filt/Fcn1'],...
		'Expr','sin(u[1]+Ph)',...
		'position',[230,105,325,135])

add_block('built-in/Note',[sys,'/','USB-AM/QAM discr-filt/Ref: Hambley: An Intro to Comm. Systems. pp72'])
set_param([sys,'/','USB-AM/QAM discr-filt/Ref: Hambley: An Intro to Comm. Systems. pp72'],...
		'position',[250,305,255,310])

add_block('built-in/Product',[sys,'/','USB-AM/QAM discr-filt/Product'])
set_param([sys,'/','USB-AM/QAM discr-filt/Product'],...
		'position',[355,47,380,78])

add_block('built-in/Product',[sys,'/','USB-AM/QAM discr-filt/Product1'])
set_param([sys,'/','USB-AM/QAM discr-filt/Product1'],...
		'position',[355,112,380,143])

add_block('built-in/Sum',[sys,'/','USB-AM/QAM discr-filt/Sum2'])
set_param([sys,'/','USB-AM/QAM discr-filt/Sum2'],...
		'position',[430,90,450,110])

add_block('built-in/Outport',[sys,'/','USB-AM/QAM discr-filt/out_1'])
set_param([sys,'/','USB-AM/QAM discr-filt/out_1'],...
		'position',[490,90,510,110])

add_block('built-in/Inport',[sys,'/','USB-AM/QAM discr-filt/in_1'])
set_param([sys,'/','USB-AM/QAM discr-filt/in_1'],...
		'position',[160,30,180,50])

add_block('built-in/Inport',[sys,'/','USB-AM/QAM discr-filt/in_2'])
set_param([sys,'/','USB-AM/QAM discr-filt/in_2'],...
		'Port','2',...
		'position',[160,145,180,165])

add_block('built-in/Gain',[sys,'/','USB-AM/QAM discr-filt/Gain'])
set_param([sys,'/','USB-AM/QAM discr-filt/Gain'],...
		'Gain','Fc',...
		'position',[130,76,180,114])

add_block('built-in/Clock',[sys,'/','USB-AM/QAM discr-filt/Clock'])
set_param([sys,'/','USB-AM/QAM discr-filt/Clock'],...
		'position',[80,85,100,105])
add_line([sys,'/','USB-AM/QAM discr-filt'],[455,100;485,100])
add_line([sys,'/','USB-AM/QAM discr-filt'],[330,70;350,70])
add_line([sys,'/','USB-AM/QAM discr-filt'],[185,40;335,40;335,55;350,55])
add_line([sys,'/','USB-AM/QAM discr-filt'],[330,120;350,120])
add_line([sys,'/','USB-AM/QAM discr-filt'],[185,155;330,155;330,135;350,135])
add_line([sys,'/','USB-AM/QAM discr-filt'],[385,65;400,65;400,95;425,95])
add_line([sys,'/','USB-AM/QAM discr-filt'],[385,130;400,130;400,105;425,105])
add_line([sys,'/','USB-AM/QAM discr-filt'],[105,95;125,95])
add_line([sys,'/','USB-AM/QAM discr-filt'],[185,95;200,95;200,70;225,70])
add_line([sys,'/','USB-AM/QAM discr-filt'],[200,95;200,120;225,120])
set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'Mask Display','QM DSB\nAM',...
		'Mask Type','Quadrature Multiplexed DSB-SC AM')
set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'Mask Dialogue','Quadrature multiplexed double-sideband suppressed-carrier amplitude modulation:|Amplitude scale factor:|Carrier frequency (Hz):|Initial phase (rad):|Sample time:')
set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'Mask Translate','Am=@1;Fc=@2*2*pi;Ph=@3;ts=@4;')
set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'Mask Help','The Quadratic Multiplexed Double-Sideband-Supressed-Carrier AM block causes the amplitude of the sinusoidal carrier to depend on the input message signal, resulting in amplitude modulation. There are two input signal being modulated at the same time by using two orthogonal sinusoidal carriers.')
set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'Mask Entries','1\/Fc\/Ph\/ts\/')


%     Finished composite block 'USB-AM/QAM discr-filt'.

set_param([sys,'/','USB-AM/QAM discr-filt'],...
		'ForeGround',3,...
		'position',[280,45,360,85])
add_line([sys,'/','USB-AM'],[220,85;240,85;240,75;275,75])
add_line([sys,'/','USB-AM'],[155,85;180,85])
add_line([sys,'/','USB-AM'],[55,30;65,30;65,85;90,85])
add_line([sys,'/','USB-AM'],[55,30;255,30;255,55;275,55])
add_line([sys,'/','USB-AM'],[365,65;395,65])
set_param([sys,'/','USB-AM'],...
		'Mask Display','plot(0,0,100,100,x,y);SSB AM',...
		'Mask Type','Passband SSB-AM')
set_param([sys,'/','USB-AM'],...
		'Mask Dialogue','Modulate the input signal using \nsingle-sideband amplitude modulation\nmethod with Hilbert transform filter.|Carrier frequency (Hz):|Initial Phase (rad):|Bandwidth of the input signal (Hz):|Time delay for Hilbert transform filter (sec):|Sample time (sec):|"upper" sideband or "lower" sideband:')
set_param([sys,'/','USB-AM'],...
		'Mask Translate','Fc=@1;Ph=@2;ban=@3;dly=@4;ts=@5;sd=@6;if ban>1/ts, ban=1/ts-ts;end;[num,den]=hilbiir(ts,dly,ban);pi2=2*pi;pih=pi/2;k=-1;if sd(1)==''l'',k=1;end;[x,y]=moduicon(1);')
set_param([sys,'/','USB-AM'],...
		'Mask Help','This block modulates the input signal using the SSB-AM method. The block uses Hilbert transfer filter. Hilbert transform filter is a non-causal filter. A positive time delay is requested in the implementation. You can specify the modulation to be an USB or LSB modulation.')
set_param([sys,'/','USB-AM'],...
		'Mask Entries','100/2/pi\/pi/2\/1/ts/10\/ts*10\/ts\/''upper''\/')


%     Finished composite block 'USB-AM'.

set_param([sys,'/','USB-AM'],...
		'ForeGround',3,...
		'position',[110,38,190,82])


%     Subsystem  ['SSB-ADM',13,'passband1'].

new_system([sys,'/',['SSB-ADM',13,'passband1']])
set_param([sys,'/',['SSB-ADM',13,'passband1']],'Location',[234,472,778,662])

add_block('built-in/Filter',[sys,'/',['SSB-ADM',13,'passband1/Filter']])
set_param([sys,'/',['SSB-ADM',13,'passband1/Filter']],...
		'Numerator','num',...
		'Denominator','den',...
		'Sample time','ts',...
		'position',[390,61,445,99])

add_block('built-in/Note',[sys,'/',['SSB-ADM',13,'passband1/Ref: Hambley: An Intro to Comm. Systems. pp72']])
set_param([sys,'/',['SSB-ADM',13,'passband1/Ref: Hambley: An Intro to Comm. Systems. pp72']],...
		'position',[285,280,290,285])

add_block('built-in/Fcn',[sys,'/',['SSB-ADM',13,'passband1/Fcn']])
set_param([sys,'/',['SSB-ADM',13,'passband1/Fcn']],...
		'Expr','cos(u[1]+Ph)',...
		'position',[205,55,300,85])

add_block('built-in/Product',[sys,'/',['SSB-ADM',13,'passband1/Product']])
set_param([sys,'/',['SSB-ADM',13,'passband1/Product']],...
		'position',[330,62,355,93])

add_block('built-in/Outport',[sys,'/',['SSB-ADM',13,'passband1/out_1']])
set_param([sys,'/',['SSB-ADM',13,'passband1/out_1']],...
		'position',[480,70,500,90])

⌨️ 快捷键说明

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