📄 tstcdma.m
字号:
function [ret,x0,str,ts,xts]=tstcdma(t,x,u,flag);
%TSTCDMA is the M-file description of the SIMULINK system named TSTCDMA.
% The block-diagram can be displayed by typing: TSTCDMA.
%
% SYS=TSTCDMA(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 TSTCDMA 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 TSTCDMA with a FLAG of zero:
% [SIZES]=TSTCDMA([],[],[],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',[63,52,992,334])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '400')
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', '')
set_param(sys,'Load callback','F0=50;F2=80;F4=110;ts=.002;[num0,den0]=butter(2,F0/2*ts);[num4,den4]=butter(2,F4/2*ts);[num2,den2]=butter(2,F2/2*ts);');
add_block('built-in/Mux',[sys,'/','Mux5'])
set_param([sys,'/','Mux5'],...
'hide name',0,...
'inputs','2',...
'position',[810,21,845,54])
add_block('built-in/Scope',[sys,'/','element 1'])
set_param([sys,'/','element 1'],...
'Vgain','1.500000',...
'Hgain','4.000000',...
'Vmax','3.000000',...
'Hmax','8.000000',...
'Window',[8,348,349,632])
open_system([sys,'/','element 1'])
set_param([sys,'/','element 1'],...
'position',[880,27,900,53])
add_block('built-in/Scope',[sys,'/','element 2'])
set_param([sys,'/','element 2'],...
'Vgain','1.500000',...
'Hgain','4.000000',...
'Vmax','3.000000',...
'Hmax','8.000000',...
'Window',[344,348,678,635])
open_system([sys,'/','element 2'])
set_param([sys,'/','element 2'],...
'position',[875,82,895,108])
add_block('built-in/Mux',[sys,'/','Mux4'])
set_param([sys,'/','Mux4'],...
'hide name',0,...
'inputs','2',...
'position',[815,76,850,109])
add_block('built-in/Mux',[sys,'/','Mux3'])
set_param([sys,'/','Mux3'],...
'hide name',0,...
'inputs','2',...
'position',[815,141,850,174])
add_block('built-in/Note',[sys,'/','Code division multiaccess example (frequency hoping method).'])
set_param([sys,'/','Code division multiaccess example (frequency hoping method).'],...
'position',[300,220,305,225])
add_block('built-in/Note',[sys,'/','Time-division access combines with frequency-division access.'])
set_param([sys,'/','Time-division access combines with frequency-division access.'],...
'position',[300,240,305,245])
% Subsystem ['Time delayed',13,'control pulse'].
new_system([sys,'/',['Time delayed',13,'control pulse']])
set_param([sys,'/',['Time delayed',13,'control pulse']],'Location',[442,574,1004,748])
add_block('built-in/Inport',[sys,'/',['Time delayed',13,'control pulse/in_1']])
set_param([sys,'/',['Time delayed',13,'control pulse/in_1']],...
'position',[30,35,50,55])
add_block('built-in/Unit Delay',[sys,'/',['Time delayed',13,'control pulse/Unit Delay']])
set_param([sys,'/',['Time delayed',13,'control pulse/Unit Delay']],...
'Sample time','100*ts',...
'position',[105,37,155,53])
% Subsystem ['Time delayed',13,'control pulse/Rising edge',13,'detector'].
new_system([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],'Location',[282,116,671,290])
add_block('built-in/Outport',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/out_1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/out_1']],...
'position',[340,25,360,45])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator1']],...
'position',[200,88,230,112])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator2']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator2']],...
'Operator','>',...
'position',[265,23,295,47])
add_block('built-in/Constant',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/one1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/one1']],...
'Value','thld',...
'position',[30,135,60,155])
add_block('built-in/Memory',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Memory1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Memory1']],...
'position',[125,80,165,110])
add_block('built-in/Inport',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/in_1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/in_1']],...
'position',[10,15,30,35])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector/Relational',13,'Operator']],...
'position',[135,18,165,42])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[35,25;130,25])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[45,25;45,95;120,95])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[170,95;195,95])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[65,145;100,145;100,35;130,35])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[100,145;180,145;180,105;195,105])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[170,30;260,30])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[235,100;240,100;240,40;260,40])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],[300,35;335,35])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],...
'Mask Display','Edge\nDetector',...
'Mask Type','Edge Detection',...
'Mask Dialogue','Rising edge detection:|Threshold:',...
'Mask Translate','thld=@1;')
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],...
'Mask Help','When the input signal rising edge passed the given shreshold, this block outputs one, otherwise outputs zero.',...
'Mask Entries','0.5\/')
% Finished composite block ['Time delayed',13,'control pulse/Rising edge',13,'detector'].
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector']],...
'position',[200,23,275,67])
add_block('built-in/Unit Delay',[sys,'/',['Time delayed',13,'control pulse/Unit Delay1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Unit Delay1']],...
'Sample time','[100*ts, 50*ts]',...
'position',[105,97,155,113])
% Subsystem ['Time delayed',13,'control pulse/Rising edge',13,'detector1'].
new_system([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],'Location',[282,116,671,290])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator']],...
'position',[135,18,165,42])
add_block('built-in/Inport',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/in_1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/in_1']],...
'position',[10,15,30,35])
add_block('built-in/Memory',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Memory1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Memory1']],...
'position',[125,80,165,110])
add_block('built-in/Constant',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/one1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/one1']],...
'Value','thld',...
'position',[30,135,60,155])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator2']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator2']],...
'Operator','>',...
'position',[265,23,295,47])
add_block('built-in/Relational Operator',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/Relational',13,'Operator1']],...
'position',[200,88,230,112])
add_block('built-in/Outport',[sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/out_1']])
set_param([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1/out_1']],...
'position',[340,25,360,45])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[300,35;335,35])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[235,100;240,100;240,40;260,40])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[170,30;260,30])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[65,145;100,145;100,35;130,35])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[100,145;180,145;180,105;195,105])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[170,95;195,95])
add_line([sys,'/',['Time delayed',13,'control pulse/Rising edge',13,'detector1']],[35,25;130,25])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -