📄 com_util.m
字号:
'Port','3',...
'position',[315,60,335,80])
% Subsystem ['Error',13,'counter/Counter/Rising edge',13,'detector1'].
new_system([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],'Location',[303,485,692,659])
add_block('built-in/Relational Operator',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator']],...
'position',[135,18,165,42])
add_block('built-in/Inport',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/in_1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/in_1']],...
'position',[10,15,30,35])
add_block('built-in/Memory',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Memory1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Memory1']],...
'position',[125,80,165,110])
add_block('built-in/Constant',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/one1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/one1']],...
'Value','thld',...
'position',[30,135,60,155])
add_block('built-in/Relational Operator',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator2']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator2']],...
'Operator','>',...
'position',[265,23,295,47])
add_block('built-in/Relational Operator',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/Relational',13,'Operator1']],...
'position',[200,88,230,112])
add_block('built-in/Outport',[sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/out_1']])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1/out_1']],...
'position',[340,25,360,45])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[300,35;335,35])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[235,100;240,100;240,40;260,40])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[170,30;260,30])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[65,145;100,145;100,35;130,35])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[100,145;180,145;180,105;195,105])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[170,95;195,95])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[35,25;130,25])
add_line([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],[45,25;45,95;120,95])
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],...
'Mask Display','Edge\ndetector',...
'Mask Type','Edge Detection',...
'Mask Dialogue','Rising edge detection:|Threshold:',...
'Mask Translate','thld=@1;')
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],...
'Mask Help','When the input signal rising edge passed the given shreshold, this block outputs one, otherwise outputs zero.',...
'Mask Entries','thld\/')
% Finished composite block ['Error',13,'counter/Counter/Rising edge',13,'detector1'].
set_param([sys,'/',['Error',13,'counter/Counter/Rising edge',13,'detector1']],...
'ForeGround',4,...
'position',[375,53,435,87])
add_line([sys,'/',['Error',13,'counter/Counter']],[440,70;450,70;450,155;465,155])
add_line([sys,'/',['Error',13,'counter/Counter']],[395,220;275,220;275,175;340,175])
add_line([sys,'/',['Error',13,'counter/Counter']],[275,175;275,115;290,115])
add_line([sys,'/',['Error',13,'counter/Counter']],[145,165;340,165])
add_line([sys,'/',['Error',13,'counter/Counter']],[260,65;275,65;275,105;290,105])
add_line([sys,'/',['Error',13,'counter/Counter']],[140,110;190,110;190,70;220,70])
add_line([sys,'/',['Error',13,'counter/Counter']],[320,110;330,110;340,155])
add_line([sys,'/',['Error',13,'counter/Counter']],[40,60;220,60])
add_line([sys,'/',['Error',13,'counter/Counter']],[40,165;75,165])
add_line([sys,'/',['Error',13,'counter/Counter']],[340,70;370,70])
add_line([sys,'/',['Error',13,'counter/Counter']],[375,165;465,165])
add_line([sys,'/',['Error',13,'counter/Counter']],[500,155;545,155])
add_line([sys,'/',['Error',13,'counter/Counter']],[520,155;520,220;445,220])
set_param([sys,'/',['Error',13,'counter/Counter']],...
'Mask Display','Number\nCounter',...
'Mask Type','Number Counter',...
'Mask Dialogue','Number counter:|Threshold:',...
'Mask Translate','thld=@1;')
set_param([sys,'/',['Error',13,'counter/Counter']],...
'Mask Help','If the signal at the first port is larger than the given threshold at the time of the clock raising edge, the counter increases one. The clock signl is provided at the second port. The raising edge of the third port clears the counter, which enforces the counter to be zero regardless the signal in port one and two.')
set_param([sys,'/',['Error',13,'counter/Counter']],...
'Mask Entries','.2\/')
% Finished composite block ['Error',13,'counter/Counter'].
set_param([sys,'/',['Error',13,'counter/Counter']],...
'position',[365,43,425,87])
add_block('built-in/Relational Operator',[sys,'/',['Error',13,'counter/Relational',13,'Operator']])
set_param([sys,'/',['Error',13,'counter/Relational',13,'Operator']],...
'Operator','>',...
'position',[270,38,300,62])
add_block('built-in/Abs',[sys,'/',['Error',13,'counter/Abs']])
set_param([sys,'/',['Error',13,'counter/Abs']],...
'position',[195,33,225,57])
add_block('built-in/Sum',[sys,'/',['Error',13,'counter/Sum']])
set_param([sys,'/',['Error',13,'counter/Sum']],...
'inputs','+-',...
'position',[140,35,160,55])
add_block('built-in/Inport',[sys,'/',['Error',13,'counter/in_2']])
set_param([sys,'/',['Error',13,'counter/in_2']],...
'Port','2',...
'position',[80,40,100,60])
add_block('built-in/Outport',[sys,'/',['Error',13,'counter/out_1']])
set_param([sys,'/',['Error',13,'counter/out_1']],...
'position',[460,55,480,75])
add_block('built-in/Inport',[sys,'/',['Error',13,'counter/in_3']])
set_param([sys,'/',['Error',13,'counter/in_3']],...
'Port','3',...
'position',[250,95,270,115])
add_block('built-in/Constant',[sys,'/',['Error',13,'counter/Constant']])
set_param([sys,'/',['Error',13,'counter/Constant']],...
'Value','tol',...
'position',[185,80,205,100])
add_block('built-in/Inport',[sys,'/',['Error',13,'counter/in_4']])
set_param([sys,'/',['Error',13,'counter/in_4']],...
'Port','4',...
'position',[295,115,315,135])
add_line([sys,'/',['Error',13,'counter']],[65,25;110,25;110,40;135,40])
add_line([sys,'/',['Error',13,'counter']],[105,50;135,50])
add_line([sys,'/',['Error',13,'counter']],[165,45;190,45])
add_line([sys,'/',['Error',13,'counter']],[230,45;265,45])
add_line([sys,'/',['Error',13,'counter']],[210,90;235,90;235,55;265,55])
add_line([sys,'/',['Error',13,'counter']],[305,50;360,50])
add_line([sys,'/',['Error',13,'counter']],[275,105;315,105;315,65;360,65])
add_line([sys,'/',['Error',13,'counter']],[320,125;335,125;335,80;360,80])
add_line([sys,'/',['Error',13,'counter']],[430,65;455,65])
set_param([sys,'/',['Error',13,'counter']],...
'Mask Display','plot(0,0,100,100,x,y,v,w);Err count',...
'Mask Type','Error counter')
set_param([sys,'/',['Error',13,'counter']],...
'Mask Dialogue','If the 1st and 2nd inport values do\nnot match at the rising edge of the\n3rd inport, the counter increases by one.|Threshold:|Tolerance:')
set_param([sys,'/',['Error',13,'counter']],...
'Mask Translate','thld=@1;tol=@2;[v,w]=trigicon(0,35,get_param(gcb,''orientation''),2);[x,y]=trigicon(0,15,get_param(gcb,''orientation''),2);')
set_param([sys,'/',['Error',13,'counter']],...
'Mask Help','If the signals at the 1st and 2nd inport do not match at the rising edge of the 3rd inport pulse, the counter increases by one. The rising edge of the 4th inport resets the counter to zero.')
set_param([sys,'/',['Error',13,'counter']],...
'Mask Entries','0.2\/eps\/')
% Finished composite block ['Error',13,'counter'].
set_param([sys,'/',['Error',13,'counter']],...
'position',[175,418,255,462])
add_block('built-in/S-Function',[sys,'/',['Modulo',13,'operation']])
set_param([sys,'/',['Modulo',13,'operation']],...
'function name','arymodu',...
'parameters','md',...
'Mask Display','Modulo',...
'Mask Type','Modulo')
set_param([sys,'/',['Modulo',13,'operation']],...
'Mask Dialogue','Output the remainder of the input value divided by the modulo base.|Modulo base:',...
'Mask Translate','md = @1;')
set_param([sys,'/',['Modulo',13,'operation']],...
'Mask Help','This block outputs the remainder of the input value divided by the modulo base. The length of the output vector is the same as the input vector.',...
'Mask Entries','2\/')
set_param([sys,'/',['Modulo',13,'operation']],...
'position',[335,343,415,387])
add_block('built-in/S-Function',[sys,'/',['Integer vector',13,'to scalar']])
set_param([sys,'/',['Integer vector',13,'to scalar']],...
'function name','simbi2de',...
'parameters','p',...
'Mask Display','Vec to sca\nconverter',...
'Mask Type','Base M vector to decimal integer')
set_param([sys,'/',['Integer vector',13,'to scalar']],...
'Mask Dialogue','Convert base M integer with each\nposition in the input vector into scalar decimal output.|Input integer base M:',...
'Mask Translate','p=@1;')
set_param([sys,'/',['Integer vector',13,'to scalar']],...
'Mask Help','This block convert the base M vector into scalar decimal integer output. Each element of the input vector is one position of the digit of the base M integer. The 1st element in the input vector contains the 1''s position. The 2nd element in the input vector contains the M''s position.')
set_param([sys,'/',['Integer vector',13,'to scalar']],...
'Mask Entries','2\/',...
'position',[335,268,415,312])
add_block('built-in/S-Function',[sys,'/',['Integer scalar',13,'to vector']])
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'function name','simde2bi',...
'parameters','len, p',...
'Mask Display','Sca to vec\nconverter',...
'Mask Type','Decimal to base M vector')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Dialogue','Convert decimal integer input to base M\ninteger and output each position of the\nconverted integer using output vector.|Output vector length:|Conversion base M:')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Translate','len=@1;p=@2;')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Help','This block converts decimal integer scalar input to a base M integer. M must be a\npositive integer. The block outputs the base M integer using a vector. The 1st element in the output vector contains the 1''s position. The 2nd element in the output vector contains the M''s position, and so on. The output vector length is given by setting the parameter entry.')
set_param([sys,'/',['Integer scalar',13,'to vector']],...
'Mask Entries','5\/2\/',...
'position',[335,193,415,237])
add_block('built-in/S-Function',[sys,'/',['Min//max',13,'index']])
set_param([sys,'/',['Min//max',13,'index']],...
'function name','arymimai',...
'parameters','mima',...
'Mask Display','Min/Max\nindex',...
'Mask Type','Maximum/minimum index.')
set_param([sys,'/',['Min//max',13,'index']],...
'Mask Dialogue','Choose the index of the input vector with\nmaximum or minimum value.|''max'' or ''min'':',...
'Mask Translate','mima=@1;')
set_param([sys,'/',['Min//max',13,'index']],...
'Mask Help','Given a vector input, this block outputs the index of the element in the input vector, which has the minimum or maximum value. When more than one value meets the same criterion, this block outputs the smallest index number.')
set_param([sys,'/',['Min//max',13,'index']],...
'Mask Entries','''min''\/',...
'position',[335,43,415,87])
% Subsystem 'Mean and std'.
new_system([sys,'/','Mean and std'])
set_param([sys,'/','Mean and std'],'Location',[16,148,871,412])
add_block('built-in/Fcn',[sys,'/','Mean and std/Fcn4'])
set_param([sys,'/','Mean and std/Fcn4'],...
'Expr','u[1]*u[1]',...
'position',[555,107,620,133])
add_block('built-in/Mux',[sys,'/','Mean and std/Mux2'])
set_param([sys,'/','Mean and std/Mux2'],...
'inputs','2',...
'position',[515,101,545,134])
add_block('built-in/Fcn',[sys,'/','Mean and std/Fcn1'])
set_param([sys,'/','Mean and std/Fcn1'],...
'Expr','sqrt(u[1])',...
'position',[690,132,755,158])
add_block('built-in/Outport',[sys,'/',['Mean and std/Mean',13,'Squared',13,'Error1']])
set_param([sys,'/',['Mean and std/Mean',13,'Squared',13,'Error1']],...
'Port','2',...
'position',[790,135,810,155])
add_block('built-in/Sum',[sys,'/','Mean and std/Sum'])
set_param([sys,'/','Mean and std/Sum'],...
'inputs','-+',...
'position',[645,135,665,155])
add_block('built-in/Fcn',[sys,'/','Mean and std/Fcn'])
set_param([sys,'/','Mean and std/Fcn'],...
'Expr','(u[3]*(u[2]-1) + u[1]*u[1])/u[2]',...
'position',[290,136,465,164])
add_block('built-in/Unit Delay',[sys,'/','Mean and std/Unit Delay'])
set_param([sys,'/','Mean and std/Unit Delay'],...
'orientation',2,...
'Sample time','Ts',...
'position',[345,192,395,208])
add_block('built-in/Mux',[sys,'/','Mean and std/Mux'])
set_param([sys,'/','Mean and std/Mux'],...
'inputs','3',...
'position',[235,134,265,166])
add_block('built-in/Fcn',[sys,'/','Mean and std/Fcn3'])
set_param([sys,'/','Mean and std/Fcn3'],...
'Expr','(u[3]*(u[2]-1) + u[1])/u[2]',...
'position',[290,41,465,69])
add_block('built-in/Mux',[sys,'/','Mean and std/Mux1'])
set_param([sys,'/','Mean and std/Mux1'],...
'inputs','3',...
'position',[235,39,265,71])
add_block('built-in/Outport',[sys,'/','Mean and std/mean value'])
set_param([sys,'/','Mean and std/mean value'],...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -