📄 extrflip.m
字号:
function [ret,x0,str,ts,xts]=extrflip(t,x,u,flag);
%EXTRFLIP is the M-file description of the SIMULINK system named EXTRFLIP.
% The block-diagram can be displayed by typing: EXTRFLIP.
%
% SYS=EXTRFLIP(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 EXTRFLIP 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 EXTRFLIP with a FLAG of zero:
% [SIZES]=EXTRFLIP([],[],[],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',[287,179,555,556])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '3')
set_param(sys,'Min step size', '0.001')
set_param(sys,'Max step size', '.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
% Subsystem 'D flip-flop'.
new_system([sys,'/','D flip-flop'])
set_param([sys,'/','D flip-flop'],'Location',[133,229,683,418])
add_block('built-in/Transport Delay',[sys,'/','D flip-flop/Transport Delay'])
set_param([sys,'/','D flip-flop/Transport Delay'],...
'orientation',2,...
'Initial Input','ini',...
'position',[395,115,440,145])
add_block('built-in/Inport',[sys,'/','D flip-flop/in_1'])
set_param([sys,'/','D flip-flop/in_1'],...
'Port','2',...
'position',[20,50,40,70])
% Subsystem 'D flip-flop/AND'.
new_system([sys,'/','D flip-flop/AND'])
set_param([sys,'/','D flip-flop/AND'],'Location',[59,237,323,377])
add_block('built-in/Outport',[sys,'/','D flip-flop/AND/out_1'])
set_param([sys,'/','D flip-flop/AND/out_1'],...
'position',[215,65,235,85])
add_block('built-in/Combinatorial Logic',[sys,'/','D flip-flop/AND/AND'])
set_param([sys,'/','D flip-flop/AND/AND'],...
'Truth Table','[0;0;0;1]',...
'position',[130,55,185,95])
add_block('built-in/Mux',[sys,'/','D flip-flop/AND/Mux'])
set_param([sys,'/','D flip-flop/AND/Mux'],...
'inputs','2',...
'position',[65,55,95,90])
add_block('built-in/Inport',[sys,'/','D flip-flop/AND/in_1'])
set_param([sys,'/','D flip-flop/AND/in_1'],...
'position',[15,55,35,75])
add_block('built-in/Inport',[sys,'/','D flip-flop/AND/in_2'])
set_param([sys,'/','D flip-flop/AND/in_2'],...
'Port','2',...
'position',[15,70,35,90])
add_line([sys,'/','D flip-flop/AND'],[100,75;125,75])
add_line([sys,'/','D flip-flop/AND'],[40,65;60,65])
add_line([sys,'/','D flip-flop/AND'],[40,80;60,80])
add_line([sys,'/','D flip-flop/AND'],[190,75;210,75])
set_param([sys,'/','D flip-flop/AND'],...
'Mask Display','AND',...
'Mask Type','AND',...
'Mask Dialogue','AND Gate',...
'Mask Help','Calculates the logical AND of the two inputs.')
% Finished composite block 'D flip-flop/AND'.
set_param([sys,'/','D flip-flop/AND'],...
'position',[215,39,250,66])
add_block('built-in/Transport Delay',[sys,'/','D flip-flop/Transport Delay1'])
set_param([sys,'/','D flip-flop/Transport Delay1'],...
'Initial Input','1',...
'position',[80,10,130,40])
add_block('built-in/Inport',[sys,'/','D flip-flop/in_2'])
set_param([sys,'/','D flip-flop/in_2'],...
'position',[160,60,180,80])
add_block('built-in/Mux',[sys,'/','D flip-flop/Mux1'])
set_param([sys,'/','D flip-flop/Mux1'],...
'inputs','3',...
'position',[275,47,305,93])
add_block('built-in/Demux',[sys,'/','D flip-flop/Demux'])
set_param([sys,'/','D flip-flop/Demux'],...
'outputs','2',...
'position',[405,50,445,85])
add_block('built-in/Combinatorial Logic',[sys,'/','D flip-flop/Logic'])
set_param([sys,'/','D flip-flop/Logic'],...
'Truth Table','[0 1;1 0;0 1;1 0;0 1;0 1;1 0;1 0]',...
'position',[325,50,380,90])
add_block('built-in/Outport',[sys,'/','D flip-flop/out_1'])
set_param([sys,'/','D flip-flop/out_1'],...
'position',[485,50,505,70])
add_block('built-in/Outport',[sys,'/','D flip-flop/out_2'])
set_param([sys,'/','D flip-flop/out_2'],...
'Port','2',...
'position',[515,65,535,85])
add_block('built-in/Fcn',[sys,'/','D flip-flop/Fcn'])
set_param([sys,'/','D flip-flop/Fcn'],...
'orientation',2,...
'Expr','u[1]>.2',...
'position',[280,118,325,142])
add_block('built-in/Fcn',[sys,'/','D flip-flop/Fcn1'])
set_param([sys,'/','D flip-flop/Fcn1'],...
'Expr','u[1]<.2',...
'position',[150,13,180,37])
add_line([sys,'/','D flip-flop'],[310,70;320,70])
add_line([sys,'/','D flip-flop'],[385,70;400,70])
add_line([sys,'/','D flip-flop'],[450,60;460,60;460,130;445,130])
add_line([sys,'/','D flip-flop'],[185,70;270,70])
add_line([sys,'/','D flip-flop'],[450,60;480,60])
add_line([sys,'/','D flip-flop'],[450,75;510,75])
add_line([sys,'/','D flip-flop'],[135,25;145,25])
add_line([sys,'/','D flip-flop'],[185,25;200,25;210,45])
add_line([sys,'/','D flip-flop'],[45,60;210,60])
add_line([sys,'/','D flip-flop'],[45,60;60,60;60,25;75,25])
add_line([sys,'/','D flip-flop'],[255,55;270,55])
add_line([sys,'/','D flip-flop'],[390,130;330,130])
add_line([sys,'/','D flip-flop'],[275,130;250,130;250,85;270,85])
set_param([sys,'/','D flip-flop'],...
'Mask Display','D 1\n\n> 0',...
'Mask Type','D flip-flop',...
'Mask Dialogue','D flip-flop|Initial State for Output "1":',...
'Mask Translate','ini=(@1~=0);')
set_param([sys,'/','D flip-flop'],...
'Mask Help','While the clock signal is high, the output will be the same as the input signal. The flip-flop then latches to the value of the input at the trailing edge of the clock pulse for the remainder of the clock cycle.')
set_param([sys,'/','D flip-flop'],...
'Mask Entries','0\/')
% Finished composite block 'D flip-flop'.
set_param([sys,'/','D flip-flop'],...
'position',[170,31,205,84])
% Subsystem 'JK flip-flop'.
new_system([sys,'/','JK flip-flop'])
set_param([sys,'/','JK flip-flop'],'Location',[446,189,1049,421])
add_block('built-in/Fcn',[sys,'/','JK flip-flop/Fcn1'])
set_param([sys,'/','JK flip-flop/Fcn1'],...
'Expr','u[1]<.2',...
'position',[150,28,180,52])
add_block('built-in/Transport Delay',[sys,'/','JK flip-flop/Transport Delay1'])
set_param([sys,'/','JK flip-flop/Transport Delay1'],...
'Initial Input','1',...
'position',[80,25,130,55])
% Subsystem 'JK flip-flop/AND'.
new_system([sys,'/','JK flip-flop/AND'])
set_param([sys,'/','JK flip-flop/AND'],'Location',[59,237,323,377])
add_block('built-in/Inport',[sys,'/','JK flip-flop/AND/in_2'])
set_param([sys,'/','JK flip-flop/AND/in_2'],...
'Port','2',...
'position',[15,70,35,90])
add_block('built-in/Inport',[sys,'/','JK flip-flop/AND/in_1'])
set_param([sys,'/','JK flip-flop/AND/in_1'],...
'position',[15,55,35,75])
add_block('built-in/Mux',[sys,'/','JK flip-flop/AND/Mux'])
set_param([sys,'/','JK flip-flop/AND/Mux'],...
'inputs','2',...
'position',[65,55,95,90])
add_block('built-in/Combinatorial Logic',[sys,'/','JK flip-flop/AND/AND'])
set_param([sys,'/','JK flip-flop/AND/AND'],...
'Truth Table','[0;0;0;1]',...
'position',[130,55,185,95])
add_block('built-in/Outport',[sys,'/','JK flip-flop/AND/out_1'])
set_param([sys,'/','JK flip-flop/AND/out_1'],...
'position',[215,65,235,85])
add_line([sys,'/','JK flip-flop/AND'],[190,75;210,75])
add_line([sys,'/','JK flip-flop/AND'],[40,80;60,80])
add_line([sys,'/','JK flip-flop/AND'],[40,65;60,65])
add_line([sys,'/','JK flip-flop/AND'],[100,75;125,75])
set_param([sys,'/','JK flip-flop/AND'],...
'Mask Display','AND',...
'Mask Type','AND',...
'Mask Dialogue','AND Gate',...
'Mask Help','Calculates the logical AND of the two inputs.')
% Finished composite block 'JK flip-flop/AND'.
set_param([sys,'/','JK flip-flop/AND'],...
'position',[215,34,250,61])
add_block('built-in/Transport Delay',[sys,'/','JK flip-flop/Transport Delay2'])
set_param([sys,'/','JK flip-flop/Transport Delay2'],...
'orientation',2,...
'Initial Input','ini',...
'position',[385,155,435,185])
add_block('built-in/Fcn',[sys,'/','JK flip-flop/Fcn'])
set_param([sys,'/','JK flip-flop/Fcn'],...
'orientation',2,...
'Expr','u[1]>.2',...
'position',[305,158,350,182])
add_block('built-in/Inport',[sys,'/','JK flip-flop/in_3'])
set_param([sys,'/','JK flip-flop/in_3'],...
'Port','3',...
'position',[75,105,95,125])
add_block('built-in/Inport',[sys,'/','JK flip-flop/in_2'])
set_param([sys,'/','JK flip-flop/in_2'],...
'position',[50,95,70,115])
add_block('built-in/Inport',[sys,'/','JK flip-flop/in_1'])
set_param([sys,'/','JK flip-flop/in_1'],...
'Port','2',...
'position',[15,75,35,95])
add_block('built-in/Mux',[sys,'/','JK flip-flop/Mux'])
set_param([sys,'/','JK flip-flop/Mux'],...
'position',[300,87,330,133])
add_block('built-in/Combinatorial Logic',[sys,'/','JK flip-flop/Logic'])
set_param([sys,'/','JK flip-flop/Logic'],...
'Truth Table','[0 1;1 0;0 1;1 0;0 1;1 0;0 1;1 0;0 1;1 0;0 1;0 1;1 0;1 0;1 0;0 1]',...
'position',[360,90,415,130])
add_block('built-in/Demux',[sys,'/','JK flip-flop/Demux'])
set_param([sys,'/','JK flip-flop/Demux'],...
'outputs','2',...
'position',[435,90,475,125])
add_block('built-in/Outport',[sys,'/','JK flip-flop/out_2'])
set_param([sys,'/','JK flip-flop/out_2'],...
'Port','2',...
'position',[520,105,540,125])
add_block('built-in/Outport',[sys,'/','JK flip-flop/out_1'])
set_param([sys,'/','JK flip-flop/out_1'],...
'position',[550,90,570,110])
add_line([sys,'/','JK flip-flop'],[185,40;210,40])
add_line([sys,'/','JK flip-flop'],[135,40;145,40])
add_line([sys,'/','JK flip-flop'],[300,170;265,170;265,125;295,125])
add_line([sys,'/','JK flip-flop'],[380,170;355,170])
add_line([sys,'/','JK flip-flop'],[480,100;480,170;440,170])
add_line([sys,'/','JK flip-flop'],[255,50;260,50;260,95;295,95])
add_line([sys,'/','JK flip-flop'],[40,85;200,85;210,55])
add_line([sys,'/','JK flip-flop'],[40,85;45,85;45,40;75,40])
add_line([sys,'/','JK flip-flop'],[75,105;295,105])
add_line([sys,'/','JK flip-flop'],[100,115;295,115])
add_line([sys,'/','JK flip-flop'],[480,115;515,115])
add_line([sys,'/','JK flip-flop'],[480,100;545,100])
add_line([sys,'/','JK flip-flop'],[420,110;430,110])
add_line([sys,'/','JK flip-flop'],[335,110;355,110])
set_param([sys,'/','JK flip-flop'],...
'Mask Display','J 1\n\n> \n\nK 0',...
'Mask Type','JK flip-flop',...
'Mask Dialogue','JK flip-flop|Initial State for Output "1":',...
'Mask Translate','ini=(@1~=0);')
set_param([sys,'/','JK flip-flop'],...
'Mask Help','When the clock signal is high, if the uncomp- lemented output is currently zero and J becomes one, the output will change to one. K has no effect on the output in this case. If the current value of the uncomplemented output is one and K becomes one, the output will change to zero. J will have no effect on the output in this case. The system clock period is used to set the state feedback delay of the flip-flop.')
set_param([sys,'/','JK flip-flop'],...
'Mask Entries','0\/')
% Finished composite block 'JK flip-flop'.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -