📄 tutcdwmo.m
字号:
add_block('built-in/Relational Operator',[sys,'/',['Rising edge',13,'detector/Relational',13,'Operator1']])
set_param([sys,'/',['Rising edge',13,'detector/Relational',13,'Operator1']],...
'position',[200,88,230,112])
add_block('built-in/Relational Operator',[sys,'/',['Rising edge',13,'detector/Relational',13,'Operator2']])
set_param([sys,'/',['Rising edge',13,'detector/Relational',13,'Operator2']],...
'Operator','>',...
'position',[265,23,295,47])
add_block('built-in/Constant',[sys,'/',['Rising edge',13,'detector/one1']])
set_param([sys,'/',['Rising edge',13,'detector/one1']],...
'Value','thld',...
'position',[30,135,60,155])
add_block('built-in/Memory',[sys,'/',['Rising edge',13,'detector/Memory1']])
set_param([sys,'/',['Rising edge',13,'detector/Memory1']],...
'position',[125,80,165,110])
add_block('built-in/Inport',[sys,'/',['Rising edge',13,'detector/in_1']])
set_param([sys,'/',['Rising edge',13,'detector/in_1']],...
'position',[10,15,30,35])
add_block('built-in/Relational Operator',[sys,'/',['Rising edge',13,'detector/Relational',13,'Operator']])
set_param([sys,'/',['Rising edge',13,'detector/Relational',13,'Operator']],...
'position',[135,18,165,42])
add_line([sys,'/',['Rising edge',13,'detector']],[35,25;130,25])
add_line([sys,'/',['Rising edge',13,'detector']],[45,25;45,95;120,95])
add_line([sys,'/',['Rising edge',13,'detector']],[170,95;195,95])
add_line([sys,'/',['Rising edge',13,'detector']],[65,145;100,145;100,35;130,35])
add_line([sys,'/',['Rising edge',13,'detector']],[100,145;180,145;180,105;195,105])
add_line([sys,'/',['Rising edge',13,'detector']],[170,30;260,30])
add_line([sys,'/',['Rising edge',13,'detector']],[235,100;240,100;240,40;260,40])
add_line([sys,'/',['Rising edge',13,'detector']],[300,35;335,35])
set_param([sys,'/',['Rising edge',13,'detector']],...
'Mask Display','plot(0,0,100,100,x,y,v,w);Edge det.',...
'Mask Type','Edge detection')
set_param([sys,'/',['Rising edge',13,'detector']],...
'Mask Dialogue','Detect the rising edge of the input\nsignal. Output one when the rising\nedge is detected.|Threshold:')
set_param([sys,'/',['Rising edge',13,'detector']],...
'Mask Translate','thld=@1;[v,w]=trigicon(0,50,get_param(gcb,''orientation''),2);[x,y]=trigicon(1,50,get_param(gcb,''orientation''));')
set_param([sys,'/',['Rising edge',13,'detector']],...
'Mask Help','This block outputs one when the input signal reaches a value larger than or equal to the given threshold value at the current time and the value was below the threshold one time step before. Otherwise, the block outputs zero.')
set_param([sys,'/',['Rising edge',13,'detector']],...
'Mask Entries','0.5\/')
% Finished composite block ['Rising edge',13,'detector'].
set_param([sys,'/',['Rising edge',13,'detector']],...
'hide name',0,...
'position',[580,118,660,162])
% Subsystem ['Pulses divide',13,'same sample time'].
new_system([sys,'/',['Pulses divide',13,'same sample time']])
set_param([sys,'/',['Pulses divide',13,'same sample time']],'Location',[55,192,283,286])
add_block('built-in/Outport',[sys,'/',['Pulses divide',13,'same sample time/Outport']])
set_param([sys,'/',['Pulses divide',13,'same sample time/Outport']],...
'position',[160,35,180,55])
add_block('built-in/S-Function',[sys,'/',['Pulses divide',13,'same sample time/S-function1']])
set_param([sys,'/',['Pulses divide',13,'same sample time/S-function1']],...
'function name','homopuls',...
'parameters','samp_time, out_divid, offset',...
'position',[40,31,105,59])
add_line([sys,'/',['Pulses divide',13,'same sample time']],[110,45;155,45])
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'Mask Display','plot(0,0,100,100,x,y);Pulse',...
'Mask Type','Pulse generator')
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time / Divider.|Sample time (scalar, sec):|Divider (integer vector):|Offset (same length as Divider):')
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;[x,y]=srcsicon(2);')
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'Mask Help','This block generates a vector pulse. The output length is the same as the divider vector length. The ith element of the output has the sample time Sample_time/Divider(i). All elements in divider must be integers.')
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'Mask Entries','.01\/1\/0\/')
% Finished composite block ['Pulses divide',13,'same sample time'].
set_param([sys,'/',['Pulses divide',13,'same sample time']],...
'hide name',0,...
'position',[485,118,565,162])
% Subsystem ['AWGN',13,'channel'].
new_system([sys,'/',['AWGN',13,'channel']])
set_param([sys,'/',['AWGN',13,'channel']],'Location',[11,262,273,408])
add_block('built-in/Inport',[sys,'/',['AWGN',13,'channel/in_1']])
set_param([sys,'/',['AWGN',13,'channel/in_1']],...
'position',[45,10,65,30])
add_block('built-in/Outport',[sys,'/',['AWGN',13,'channel/out_1']])
set_param([sys,'/',['AWGN',13,'channel/out_1']],...
'position',[200,55,220,75])
add_block('built-in/Sum',[sys,'/',['AWGN',13,'channel/Sum']])
set_param([sys,'/',['AWGN',13,'channel/Sum']],...
'position',[150,55,170,75])
% Subsystem ['AWGN',13,'channel/Gaussian noise',13,'generator'].
new_system([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],'Location',[22,119,370,243])
add_block('built-in/State-Space',[sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Matrix',13,'Gain']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Matrix',13,'Gain']],...
'A','[]',...
'B','[]',...
'C','[]',...
'D','K',...
'Mask Display','K',...
'Mask Type','Matrix Gain')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Matrix',13,'Gain']],...
'Mask Dialogue','Matrix Gain.|Gain matrix:',...
'Mask Translate','K = @1;')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Matrix',13,'Gain']],...
'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
'Mask Entries','d\/',...
'position',[140,61,165,89])
add_block('built-in/White Noise',[sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Random',13,'Number']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Random',13,'Number']],...
'Seed','s',...
'position',[35,57,80,93])
add_block('built-in/Constant',[sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Constant']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Constant']],...
'Value','m',...
'position',[140,20,160,40])
add_block('built-in/Sum',[sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Sum']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/Sum']],...
'position',[220,60,240,80])
add_block('built-in/Outport',[sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/out_1']])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator/out_1']],...
'position',[285,60,305,80])
add_line([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],[165,30;190,30;190,65;215,65])
add_line([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],[245,70;280,70])
add_line([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],[170,75;215,75])
add_line([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],[85,75;135,75])
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'Mask Display','plot(0,0,100,100,x,y);Gaussian',...
'Mask Type','Gaussian noise generator')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'Mask Dialogue','Generate Gaussian distributed noise with\ngiven mean and variance value.|Mean value:|Variance (vector or matrix):|Initial seed:')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'Mask Translate','m=@1;d=@2;s=@3;[m,d,s]=gwnoise(m,d,s);[x,y]=srcsicon(3);')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'Mask Help','When the mean value and seed are vectors, the output of this block is a vector. The length of the vector is the same as the length of the mean value vector or the length of the seed. When the variance entry is a vector, the variance is a diagonal matrix.')
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'Mask Entries','m\/d\/s\/')
% Finished composite block ['AWGN',13,'channel/Gaussian noise',13,'generator'].
set_param([sys,'/',['AWGN',13,'channel/Gaussian noise',13,'generator']],...
'position',[25,48,105,92])
add_line([sys,'/',['AWGN',13,'channel']],[175,65;195,65])
add_line([sys,'/',['AWGN',13,'channel']],[70,20;115,20;115,60;145,60])
add_line([sys,'/',['AWGN',13,'channel']],[110,70;145,70])
set_param([sys,'/',['AWGN',13,'channel']],...
'Mask Display','plot(0,0,100,100,x,y);AWGN',...
'Mask Type','AWGN channel, fixed parameter')
set_param([sys,'/',['AWGN',13,'channel']],...
'Mask Dialogue','Additive white Gaussian noise channel\nwith fixed mean and variance.|Mean value:|Variance (std^2):|Initial Seed:')
set_param([sys,'/',['AWGN',13,'channel']],...
'Mask Translate','m=@1;d=@2;s=@3;[m,d,s]=gwnoise(m,d,s);[x,y]=chanicon;')
set_param([sys,'/',['AWGN',13,'channel']],...
'Mask Help','This block adds white Gaussian noise to the input signal. The mean and the variance can be a scalar or vector with the same length as the input signal.')
set_param([sys,'/',['AWGN',13,'channel']],...
'Mask Entries','0\/.000001\/12345\/')
% Finished composite block ['AWGN',13,'channel'].
set_param([sys,'/',['AWGN',13,'channel']],...
'hide name',0,...
'position',[390,63,470,107])
add_line(sys,[95,85;100,85])
add_line(sys,[95,85;95,35;705,35])
add_line(sys,[770,85;780,85])
add_line(sys,[795,35;880,35])
add_line(sys,[870,85;880,55])
add_line(sys,[475,85;480,85])
add_line(sys,[665,85;680,85])
add_line(sys,[190,85;195,85])
add_line(sys,[285,85;290,85])
add_line(sys,[380,85;385,85])
add_line(sys,[570,85;575,85])
add_line(sys,[570,140;575,140])
add_line(sys,[665,140;670,140;680,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 + -