📄 elg.m
字号:
function [ret,x0,str,ts,xts]=elg(t,x,u,flag);
%ELG is the M-file description of the SIMULINK system named ELG.
% The block-diagram can be displayed by typing: ELG.
%
% SYS=ELG(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 ELG 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 ELG with a FLAG of zero:
% [SIZES]=ELG([],[],[],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',[122,326,758,706])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-23')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999999')
set_param(sys,'Min step size', '1/12000/2')
set_param(sys,'Max step size', '1/12000/2')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
set_param(sys,'Load callback',['tss=1/12000;tdd=1/600;MM=2;Fc=1200;Fshift=1200;[f1num,f1den]=butter(4,2*pi*4000,''s'');f2num=fir1(127,(Fshift/2+1/tdd)*2*tss);f2den=[1,zeros(1,127)];']);
% Subsystem 'MFSK mod'.
new_system([sys,'/','MFSK mod'])
set_param([sys,'/','MFSK mod'],'Location',[624,140,1004,330])
add_block('built-in/Outport',[sys,'/','MFSK mod/out_1'])
set_param([sys,'/','MFSK mod/out_1'],...
'position',[290,60,310,80])
add_block('built-in/Inport',[sys,'/','MFSK mod/in_1'])
set_param([sys,'/','MFSK mod/in_1'],...
'position',[15,60,35,80])
% Subsystem 'MFSK mod/MFSK map'.
new_system([sys,'/','MFSK mod/MFSK map'])
set_param([sys,'/','MFSK mod/MFSK map'],'Location',[90,420,407,543])
add_block('built-in/Zero-Order Hold',[sys,'/',['MFSK mod/MFSK map/Zero-Order',13,'Hold1']])
set_param([sys,'/',['MFSK mod/MFSK map/Zero-Order',13,'Hold1']],...
'Sample time','td',...
'position',[105,39,140,71])
add_block('built-in/Outport',[sys,'/','MFSK mod/MFSK map/out_1'])
set_param([sys,'/','MFSK mod/MFSK map/out_1'],...
'position',[260,45,280,65])
add_block('built-in/Gain',[sys,'/','MFSK mod/MFSK map/Gain'])
set_param([sys,'/','MFSK mod/MFSK map/Gain'],...
'Gain','Ton',...
'position',[175,38,225,72])
add_block('built-in/Inport',[sys,'/','MFSK mod/MFSK map/in_1'])
set_param([sys,'/','MFSK mod/MFSK map/in_1'],...
'position',[45,45,65,65])
add_line([sys,'/','MFSK mod/MFSK map'],[145,55;170,55])
add_line([sys,'/','MFSK mod/MFSK map'],[70,55;100,55])
add_line([sys,'/','MFSK mod/MFSK map'],[230,55;255,55])
set_param([sys,'/','MFSK mod/MFSK map'],...
'Mask Display','MFSK\nmap',...
'Mask Type','MFSK map')
set_param([sys,'/','MFSK mod/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/MFSK map'],...
'Mask Translate','Ton=@1;td=@2;')
set_param([sys,'/','MFSK mod/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/MFSK map'],...
'Mask Entries','Ton\/td\/')
% Finished composite block 'MFSK mod/MFSK map'.
set_param([sys,'/','MFSK mod/MFSK map'],...
'position',[75,48,155,92])
% Subsystem ['MFSK mod/FM',13,'passband'].
new_system([sys,'/',['MFSK mod/FM',13,'passband']])
set_param([sys,'/',['MFSK mod/FM',13,'passband']],'Location',[102,348,590,498])
add_block('built-in/Inport',[sys,'/',['MFSK mod/FM',13,'passband/in_1']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/in_1']],...
'position',[60,40,80,60])
add_block('built-in/Outport',[sys,'/',['MFSK mod/FM',13,'passband/out_1']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/out_1']],...
'position',[465,50,485,70])
add_block('built-in/Fcn',[sys,'/',['MFSK mod/FM',13,'passband/sin']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/sin']],...
'Expr','cos(u[1]*pi2+Ph)',...
'position',[290,45,430,75])
add_block('built-in/Constant',[sys,'/',['MFSK mod/FM',13,'passband/Constant']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/Constant']],...
'Value','Fc',...
'position',[40,85,60,105])
add_block('built-in/S-Function',[sys,'/',['MFSK mod/FM',13,'passband/Scheduled',13,'reset-int']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/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/FM',13,'passband/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/FM',13,'passband/Scheduled',13,'reset-int']],...
'Mask Translate','td=@1;ts=@2;limit=@3;')
set_param([sys,'/',['MFSK mod/FM',13,'passband/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/FM',13,'passband/Scheduled',13,'reset-int']],...
'Mask Entries','td\/ts\/Inf\/',...
'position',[200,39,260,81])
add_block('built-in/Sum',[sys,'/',['MFSK mod/FM',13,'passband/Sum']])
set_param([sys,'/',['MFSK mod/FM',13,'passband/Sum']],...
'position',[130,42,150,78])
add_line([sys,'/',['MFSK mod/FM',13,'passband']],[435,60;460,60])
add_line([sys,'/',['MFSK mod/FM',13,'passband']],[265,60;285,60])
add_line([sys,'/',['MFSK mod/FM',13,'passband']],[155,60;195,60])
add_line([sys,'/',['MFSK mod/FM',13,'passband']],[65,95;90,95;90,70;125,70])
add_line([sys,'/',['MFSK mod/FM',13,'passband']],[85,50;125,50])
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'Mask Display','plot(0,0,100,100,x,y);FM',...
'Mask Type','Passband FM')
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'Mask Dialogue','Modulate the input signal using FM method.|Carrier frequency (Hz):|Initial phase (rad):|Sample time (sec):|Symbol interval (sec; Use Inf for analog mod);')
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'Mask Translate','Fc=@1;Ph=@2;pi2=2*pi;ts=@3;td=@4;if isinf(td),td=inf;end;[x,y]=moduicon(3);')
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'Mask Help','This block modulates the input signal using frequency modulation method. The frequency of the output of the carrier signal depends on the amplitude of the input signal.')
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'Mask Entries','Fc\/Ph\/ts\/td\/')
% Finished composite block ['MFSK mod/FM',13,'passband'].
set_param([sys,'/',['MFSK mod/FM',13,'passband']],...
'ForeGround',4,...
'position',[190,48,270,92])
add_line([sys,'/','MFSK mod'],[40,70;70,70])
add_line([sys,'/','MFSK mod'],[275,70;285,70])
add_line([sys,'/','MFSK mod'],[160,70;185,70])
set_param([sys,'/','MFSK mod'],...
'Mask Display','plot(0,0,100,100,x,y);MFSK',...
'Mask Type','Passband FSK modulation')
set_param([sys,'/','MFSK mod'],...
'Mask Dialogue','Modulate the input digital signal using M-ary frequency shift keying method.|Tone space(Hz):|Symbol interval (sec):|Carrier frequency (Hz):|Initial phase (rad):|Sample frequency (sec):')
set_param([sys,'/','MFSK mod'],...
'Mask Translate','Ton=@1;td=@2;Fc=@3;Ph=@4;ts=@5;[x,y]=moduicon(7);')
set_param([sys,'/','MFSK mod'],...
'Mask Help','This block modulates a digital signal using FSK method. The modulation resets the modulation phase to be the specified initial phase at the beginning of each digit. Tone space is the frequency distance between two consecutive digits after modulation. The output signal has its frequency in the range [Fc, Fc + Tone_space*Max_In_Value], where Fc is the carrier frequency.')
set_param([sys,'/','MFSK mod'],...
'Mask Entries','Fshift\/tdd\/Fc\/0\/tss\/')
% Finished composite block 'MFSK mod'.
set_param([sys,'/','MFSK mod'],...
'hide name',0,...
'position',[180,23,260,67])
% Subsystem ['Sampled read',13,'from wksp'].
new_system([sys,'/',['Sampled read',13,'from wksp']])
set_param([sys,'/',['Sampled read',13,'from wksp']],'Location',[355,528,737,675])
% Subsystem ['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1'].
new_system([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],'Location',[55,192,283,286])
add_block('built-in/S-Function',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']],...
'function name','homopuls',...
'parameters','samp_time, out_divid, offset',...
'position',[40,31,105,59])
add_block('built-in/Outport',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']],...
'position',[160,35,180,55])
add_line([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Display','Vector\nPulse',...
'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time ./Divider. |Sample time (scalar, sec):|Divider (integer vector):|Offset (have same dimension as Divider:')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Help','This block generator a vector pulses. The output length is the same as the vector defined in "Divider". The ith element of the output has the sample time Sample_time/Divider(i). All elements in "Divider" must be integers.')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -