📄 tsthilbt.m
字号:
function [ret,x0,str,ts,xts]=tsthilbt(t,x,u,flag);
%TSTHILBT is the M-file description of the SIMULINK system named TSTHILBT.
% The block-diagram can be displayed by typing: TSTHILBT.
%
% SYS=TSTHILBT(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 TSTHILBT 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 TSTHILBT with a FLAG of zero:
% [SIZES]=TSTHILBT([],[],[],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',[93,97,517,305])
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', '')
set_param(sys,'Load callback','M=16;td=.1;ts=.01;Fc=100/pi/2;[num,den]=butter(5,Fc*2*ts);');
add_block('built-in/Signal Generator',[sys,'/',['Signal',13,'generator']])
set_param([sys,'/',['Signal',13,'generator']],...
'ForeGround',5,...
'hide name',0,...
'Peak','1.000000',...
'Peak Range','5.000000',...
'Freq','1.000000',...
'Freq Range','50.000000',...
'Wave','Sin',...
'Units','Rads')
set_param([sys,'/',['Signal',13,'generator']],...
'position',[35,23,80,57])
add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
'hide name',0,...
'inputs','2',...
'position',[270,65,305,100])
% Subsystem ['Auto-Scale',13,'Graph'].
new_system([sys,'/',['Auto-Scale',13,'Graph']])
set_param([sys,'/',['Auto-Scale',13,'Graph']],'Location',[0,59,274,252])
add_block('built-in/S-Function',[sys,'/',['Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Auto-Scale',13,'Graph/S-function',13,'M-file which plots',13,'lines',13,'']],...
'function name','sfunyst',...
'parameters','ax, color, npts, dt',...
'position',[130,55,180,75])
add_block('built-in/Inport',[sys,'/',['Auto-Scale',13,'Graph/x']])
set_param([sys,'/',['Auto-Scale',13,'Graph/x']],...
'position',[65,55,85,75])
add_line([sys,'/',['Auto-Scale',13,'Graph']],[90,65;125,65])
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
'Mask Type','Storage scope.')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):|Sample time:')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3]; dt=@6;')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Help','Uses MATLAB''s graph window.\nUse only one block per system.\nLine type must be in quotes.\nSee the M-file sfunyst.m.')
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'Mask Entries','5\/-10\/10\/200\/''y--/g-/m-./w:/m*/ro/b+''\/.1\/')
% Finished composite block ['Auto-Scale',13,'Graph'].
set_param([sys,'/',['Auto-Scale',13,'Graph']],...
'hide name',0,...
'position',[355,65,385,105])
add_block('built-in/Note',[sys,'/',['The Hilbert transform filter shifts the phase of the input signal.',13,'Because of the implementation of the filter, delays are added',13,'in the implementation of the Hilbert transform filter. ']])
set_param([sys,'/',['The Hilbert transform filter shifts the phase of the input signal.',13,'Because of the implementation of the filter, delays are added',13,'in the implementation of the Hilbert transform filter. ']],...
'position',[210,145,215,150])
% Subsystem 'Hilbert transform filter'.
new_system([sys,'/','Hilbert transform filter'])
set_param([sys,'/','Hilbert transform filter'],'Location',[117,572,380,656])
add_block('built-in/Filter',[sys,'/','Hilbert transform filter/Filter'])
set_param([sys,'/','Hilbert transform filter/Filter'],...
'Numerator','num',...
'Denominator','den',...
'Sample time','ts',...
'position',[95,11,150,49])
add_block('built-in/Inport',[sys,'/','Hilbert transform filter/in_1'])
set_param([sys,'/','Hilbert transform filter/in_1'],...
'position',[35,20,55,40])
add_block('built-in/Outport',[sys,'/','Hilbert transform filter/out_1'])
set_param([sys,'/','Hilbert transform filter/out_1'],...
'position',[195,20,215,40])
add_block('built-in/Note',[sys,'/','Hilbert transform filter/Ref: Hambley: An Intro to Comm. Systems. pp82'])
set_param([sys,'/','Hilbert transform filter/Ref: Hambley: An Intro to Comm. Systems. pp82'],...
'position',[355,290,360,295])
add_line([sys,'/','Hilbert transform filter'],[155,30;190,30])
add_line([sys,'/','Hilbert transform filter'],[60,30;90,30])
set_param([sys,'/','Hilbert transform filter'],...
'Mask Display','Hilbert\nfilter',...
'Mask Type','Hilbert transform filter')
set_param([sys,'/','Hilbert transform filter'],...
'Mask Dialogue','Design a Hilbert transform filter and use it to filter the input signal.|Bandwidth of the input signal (Hz):|Time delay for Hilbert transform filter (sec):|Sample time (sec):')
set_param([sys,'/','Hilbert transform filter'],...
'Mask Translate','ban=@1;dly=@2;ts=@3;if ban>1/ts, ban=1/ts-ts;end;[num,den]=hilbiir(ts,dly,ban);pi2=2*pi;pih=pi/2;')
set_param([sys,'/','Hilbert transform filter'],...
'Mask Help','This block designs a Hilbert transform filter. The filter is used to filter the input signal. Hilbert transform filter is a non-causal filter and needs a positive time delay. The filter works with the signal in the given frequency range.')
set_param([sys,'/','Hilbert transform filter'],...
'Mask Entries','1/2/pi\/ts*10\/ts\/')
% Finished composite block 'Hilbert transform filter'.
set_param([sys,'/','Hilbert transform filter'],...
'ForeGround',3,...
'hide name',0,...
'position',[140,68,220,112])
add_line(sys,[85,40;115,40;115,90;135,90])
add_line(sys,[225,90;265,90])
add_line(sys,[115,40;255,40;265,75])
add_line(sys,[310,85;350,85])
drawnow
% Return any arguments.
if (nargin | nargout)
% Must use feval here to access system in memory
if (nargin > 3)
if (flag == 0)
eval(['[ret,x0,str,ts,xts]=',sys,'(t,x,u,flag);'])
else
eval(['ret =', sys,'(t,x,u,flag);'])
end
else
[ret,x0,str,ts,xts] = feval(sys);
end
else
drawnow % Flash up the model and execute load callback
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -