📄 s2.m
字号:
'Mask Display','S 1\n\nR 0',...
'Mask Type','Latch',...
'Mask Dialogue','Latch|Initial State for Output "1":',...
'Mask Translate','ini=(@1~=0);')
set_param([sys,'/','breaker/Latch3'],...
'Mask Help','Latches the S input. When S (set) is one, the uncomplemented output (1) becomes one. The output remains one until the R (reset) input becomes one, forcing the output to zero. If both R and S are one, the latch will be in an undefined state.')
set_param([sys,'/','breaker/Latch3'],...
'Mask Entries','0\/')
% Finished composite block 'breaker/Latch3'.
set_param([sys,'/','breaker/Latch3'],...
'position',[310,435,345,475])
add_block('built-in/Transport Delay',[sys,'/','breaker/delay to'])
set_param([sys,'/','breaker/delay to'],...
'orientation',2,...
'Delay Time','to',...
'position',[345,507,400,543])
add_block('built-in/Fcn',[sys,'/','breaker/abs(iS)'])
set_param([sys,'/','breaker/abs(iS)'],...
'orientation',2,...
'Expr','abs(u[1])',...
'position',[615,483,650,517])
add_block('built-in/Logical Operator',[sys,'/',['breaker/t0 delay',13,'enable']])
set_param([sys,'/',['breaker/t0 delay',13,'enable']],...
'orientation',2,...
'Operator','AND',...
'position',[285,516,320,554])
% Subsystem 'breaker/Latch1'.
new_system([sys,'/','breaker/Latch1'])
set_param([sys,'/','breaker/Latch1'],'Location',[102,336,551,502])
add_block('built-in/Fcn',[sys,'/','breaker/Latch1/Fcn'])
set_param([sys,'/','breaker/Latch1/Fcn'],...
'orientation',2,...
'Expr','u[1]>.2',...
'position',[170,123,205,147])
add_block('built-in/Demux',[sys,'/','breaker/Latch1/Demux'])
set_param([sys,'/','breaker/Latch1/Demux'],...
'outputs','2',...
'position',[275,55,315,90])
add_block('built-in/Combinatorial Logic',[sys,'/','breaker/Latch1/Logic'])
set_param([sys,'/','breaker/Latch1/Logic'],...
'Truth Table','[0 1;1 0;0 1;0 1;1 0;1 0;0 0;0 0]',...
'position',[195,55,250,95])
add_block('built-in/Transport Delay',[sys,'/','breaker/Latch1/Transport Delay'])
set_param([sys,'/','breaker/Latch1/Transport Delay'],...
'orientation',2,...
'Initial Input','ini',...
'position',[250,120,295,150])
add_block('built-in/Outport',[sys,'/','breaker/Latch1/out_2'])
set_param([sys,'/','breaker/Latch1/out_2'],...
'Port','2',...
'position',[395,70,415,90])
add_block('built-in/Outport',[sys,'/','breaker/Latch1/out_1'])
set_param([sys,'/','breaker/Latch1/out_1'],...
'position',[355,55,375,75])
add_block('built-in/Mux',[sys,'/','breaker/Latch1/Mux'])
set_param([sys,'/','breaker/Latch1/Mux'],...
'inputs','3',...
'position',[135,59,165,91])
add_block('built-in/Inport',[sys,'/','breaker/Latch1/in_1'])
set_param([sys,'/','breaker/Latch1/in_1'],...
'position',[20,50,40,70])
add_block('built-in/Inport',[sys,'/','breaker/Latch1/in_2'])
set_param([sys,'/','breaker/Latch1/in_2'],...
'Port','2',...
'position',[50,65,70,85])
add_line([sys,'/','breaker/Latch1'],[320,65;350,65])
add_line([sys,'/','breaker/Latch1'],[335,65;335,135;300,135])
add_line([sys,'/','breaker/Latch1'],[165,135;110,135;110,85;130,85])
add_line([sys,'/','breaker/Latch1'],[245,135;210,135])
add_line([sys,'/','breaker/Latch1'],[75,75;130,75])
add_line([sys,'/','breaker/Latch1'],[45,60;105,60;105,65;130,65])
add_line([sys,'/','breaker/Latch1'],[170,75;190,75])
add_line([sys,'/','breaker/Latch1'],[255,75;270,75])
add_line([sys,'/','breaker/Latch1'],[320,80;390,80])
set_param([sys,'/','breaker/Latch1'],...
'Mask Display','S 1\n\nR 0',...
'Mask Type','Latch',...
'Mask Dialogue','Latch|Initial State for Output "1":',...
'Mask Translate','ini=(@1~=0);')
set_param([sys,'/','breaker/Latch1'],...
'Mask Help','Latches the S input. When S (set) is one, the uncomplemented output (1) becomes one. The output remains one until the R (reset) input becomes one, forcing the output to zero. If both R and S are one, the latch will be in an undefined state.')
set_param([sys,'/','breaker/Latch1'],...
'Mask Entries','0\/')
% Finished composite block 'breaker/Latch1'.
set_param([sys,'/','breaker/Latch1'],...
'orientation',2,...
'position',[175,525,210,565])
add_block('built-in/Relational Operator',[sys,'/','breaker/|iS|<=eps'])
set_param([sys,'/','breaker/|iS|<=eps'],...
'orientation',2,...
'Operator','<=',...
'position',[545,526,575,564])
add_block('built-in/Constant',[sys,'/','breaker/eps'])
set_param([sys,'/','breaker/eps'],...
'orientation',2,...
'position',[615,541,635,569])
add_block('built-in/Switch',[sys,'/','breaker/Insert iS*Rc'])
set_param([sys,'/','breaker/Insert iS*Rc'],...
'orientation',2,...
'Threshold','0.5',...
'position',[175,175,195,225])
% Subsystem 'breaker/delay tc'.
new_system([sys,'/','breaker/delay tc'])
set_param([sys,'/','breaker/delay tc'],'Location',[485,451,992,690])
add_block('built-in/Note',[sys,'/',['breaker/delay tc/AND used to suppress',13,'spurious operation when',13,'input goes from high to low']])
set_param([sys,'/',['breaker/delay tc/AND used to suppress',13,'spurious operation when',13,'input goes from high to low']],...
'position',[350,178,355,183])
add_block('built-in/Logical Operator',[sys,'/',['breaker/delay tc/Logical',13,'Operator1']])
set_param([sys,'/',['breaker/delay tc/Logical',13,'Operator1']],...
'Operator','AND',...
'position',[320,42,365,138])
add_block('built-in/Outport',[sys,'/','breaker/delay tc/out_1'])
set_param([sys,'/','breaker/delay tc/out_1'],...
'position',[405,80,425,100])
add_block('built-in/Inport',[sys,'/','breaker/delay tc/in_1'])
set_param([sys,'/','breaker/delay tc/in_1'],...
'position',[20,90,40,110])
add_block('built-in/Logical Operator',[sys,'/',['breaker/delay tc/Logical',13,'Operator']])
set_param([sys,'/',['breaker/delay tc/Logical',13,'Operator']],...
'Operator','XOR',...
'position',[225,85,275,145])
add_block('built-in/Transport Delay',[sys,'/',['breaker/delay tc/Transport',13,'Delay1']])
set_param([sys,'/',['breaker/delay tc/Transport',13,'Delay1']],...
'Delay Time','tc',...
'position',[105,110,170,150])
add_line([sys,'/','breaker/delay tc'],[175,130;220,130])
add_line([sys,'/','breaker/delay tc'],[45,100;60,100;60,130;100,130])
add_line([sys,'/','breaker/delay tc'],[45,100;220,100])
add_line([sys,'/','breaker/delay tc'],[370,90;400,90])
add_line([sys,'/','breaker/delay tc'],[280,115;315,115])
add_line([sys,'/','breaker/delay tc'],[60,100;60,65;315,65])
% Finished composite block 'breaker/delay tc'.
set_param([sys,'/','breaker/delay tc'],...
'orientation',3,...
'position',[230,340,280,370])
add_block('built-in/Inport',[sys,'/',['breaker/CB on//off',13,'signal']])
set_param([sys,'/',['breaker/CB on//off',13,'signal']],...
'Port','2',...
'position',[55,380,75,400])
add_block('built-in/Outport',[sys,'/','breaker/vb'])
set_param([sys,'/','breaker/vb'],...
'Port','2',...
'position',[675,45,695,65])
add_line([sys,'/','breaker'],[650,55;670,55])
add_line([sys,'/','breaker'],[105,260;95,260;95,125;175,125])
add_line([sys,'/','breaker'],[200,125;220,125;220,55;555,55])
add_line([sys,'/','breaker'],[385,245;135,245])
add_line([sys,'/','breaker'],[200,125;335,125])
add_line([sys,'/','breaker'],[170,200;125,200;125,140;175,140])
add_line([sys,'/','breaker'],[70,25;105,25])
add_line([sys,'/','breaker'],[580,70;620,70])
add_line([sys,'/','breaker'],[130,40;620,40])
add_line([sys,'/','breaker'],[130,40;155,40;155,110;175,110])
add_line([sys,'/','breaker'],[640,150;690,150])
add_line([sys,'/','breaker'],[670,150;670,185;350,185])
add_line([sys,'/','breaker'],[390,125;525,125])
add_line([sys,'/','breaker'],[670,185;670,245;440,245])
add_line([sys,'/','breaker'],[550,140;590,140])
add_line([sys,'/','breaker'],[350,445;490,445;490,70;555,70])
add_line([sys,'/','breaker'],[490,435;490,140;525,140])
add_line([sys,'/','breaker'],[295,185;200,185])
add_line([sys,'/','breaker'],[665,245;670,245;670,500;655,500])
add_line([sys,'/','breaker'],[610,500;600,500;600,535;580,535])
add_line([sys,'/','breaker'],[610,555;580,555])
add_line([sys,'/','breaker'],[80,390;300,390])
add_line([sys,'/','breaker'],[665,150;670,150;670,105;690,105])
add_line([sys,'/','breaker'],[95,150;65,150])
add_line([sys,'/','breaker'],[155,200;65,200])
add_line([sys,'/','breaker'],[540,545;325,545])
add_line([sys,'/','breaker'],[340,525;325,525])
add_line([sys,'/','breaker'],[280,535;215,535])
add_line([sys,'/','breaker'],[255,335;255,320;355,320])
add_line([sys,'/','breaker'],[80,390;255,390;255,375])
add_line([sys,'/','breaker'],[70,70;85,70;85,50;105,50])
add_line([sys,'/','breaker'],[400,320;580,320;580,415])
add_line([sys,'/','breaker'],[340,390;565,390;565,415])
add_line([sys,'/','breaker'],[170,535;160,535;160,485])
add_line([sys,'/','breaker'],[255,385;255,445;305,445])
add_line([sys,'/','breaker'],[280,535;270,535;270,465;305,465])
add_line([sys,'/','breaker'],[540,545;525,545;525,405;595,415])
add_line([sys,'/','breaker'],[580,445;580,500;485,500])
add_line([sys,'/','breaker'],[440,500;180,500;180,485])
add_line([sys,'/','breaker'],[440,500;415,500;405,525])
add_line([sys,'/','breaker'],[580,445;580,455;550,455;550,150;590,150])
add_line([sys,'/','breaker'],[95,390;95,585;505,585;505,520;485,520])
add_line([sys,'/','breaker'],[230,585;230,555;215,555])
add_line([sys,'/','breaker'],[255,335;255,200;200,200])
add_line([sys,'/','breaker'],[170,450;170,260;135,260])
set_param([sys,'/','breaker'],...
'Mask Display','')
% Finished composite block 'breaker'.
set_param([sys,'/','breaker'],...
'position',[195,154,225,206])
add_block('built-in/Mux',[sys,'/','Mux2'])
set_param([sys,'/','Mux2'],...
'orientation',3,...
'inputs','7',...
'position',[125,85,515,100])
add_block('built-in/Note',[sys,'/',['Double click on masked block m2 in this screen or run m2.m in ',13,'MATLAB command window to initialize this simulation. ',13,'After the simulation, type return after the K>> prompt in the ',13,'MATLAB command window to plot results.']])
set_param([sys,'/',['Double click on masked block m2 in this screen or run m2.m in ',13,'MATLAB command window to initialize this simulation. ',13,'After the simulation, type return after the K>> prompt in the ',13,'MATLAB command window to plot results.']],...
'position',[315,250,320,255])
% Subsystem 'm2'.
new_system([sys,'/','m2'])
set_param([sys,'/','m2'],'Location',[-10,4391136,201,4391244])
add_block('built-in/Note',[sys,'/',['m2/Masked block of m2.m to initalize s2.m ',13,'and plot results']])
set_param([sys,'/',['m2/Masked block of m2.m to initalize s2.m ',13,'and plot results']],...
'position',[125,45,130,50])
set_param([sys,'/','m2'],...
'Mask Display','Initialize\nand plot',...
'Mask Type','Masked block of m2.m',...
'Mask Dialogue','eval(''m2'')',...
'Mask Help','Uses m2.m to initialize and plot')
% Finished composite block 'm2'.
set_param([sys,'/','m2'],...
'Drop Shadow',4,...
'position',[120,26,194,64])
add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'orientation',2,...
'Vgain','450000.000000',...
'Hgain','0.250000',...
'Vmax','900000.000000',...
'Hmax','0.500000',...
'Window',[79,364,702,581])
open_system([sys,'/','Scope'])
set_param([sys,'/','Scope'],...
'position',[250,39,270,61])
add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
'mat-name','y',...
'buffer','15000',...
'position',[380,42,430,58])
add_line(sys,[450,170;485,170;485,245;290,245;290,195;305,195])
add_line(sys,[230,170;305,170])
add_line(sys,[345,170;410,170])
add_line(sys,[150,165;190,165])
add_line(sys,[345,195;375,195;375,235;175,235;175,195;190,195])
add_line(sys,[320,80;320,50;375,50])
add_line(sys,[150,120;155,120;155,105])
add_line(sys,[145,210;160,210;160,180;190,180])
add_line(sys,[320,80;320,50;275,50])
add_line(sys,[150,165;160,165;160,145;210,145;210,105])
add_line(sys,[230,195;265,195;265,105])
add_line(sys,[230,170;255,170;255,140;320,140;320,105])
add_line(sys,[345,195;375,195;375,105])
add_line(sys,[345,170;385,170;385,135;430,135;430,105])
add_line(sys,[450,170;485,170;485,105])
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 + -