📄 tddmqask.m
字号:
add_block('built-in/Zero-Order Hold',[sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map/Zero-Order',13,'Hold']])
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map/Zero-Order',13,'Hold']],...
'Sample time','td',...
'position',[110,24,145,56])
add_block('built-in/Inport',[sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map/in_1']])
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map/in_1']],...
'position',[45,30,65,50])
add_line([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],[70,40;105,40])
add_line([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],[150,40;240,40])
add_line([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],[185,40;185,105;240,105])
add_line([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],[285,105;320,105])
add_line([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],[285,40;320,40])
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'Mask Display','QASK\nS-map',...
'Mask Type','QASK S-map')
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'Mask Dialogue','Use square constellation to map the\ninput digital signal into in-phase and\nquadrature components. M must be\nM=2^K with integer K.|M-ary number (input integers in range [0, M-1]):|Input symbol interval and offset (sec):')
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'Mask Translate','N=@1;Ac=1;td=@2;z=[[1:N];[1:N]];z=z(:);[x,y]=qaskenco(z-1,N);z=z-1.5;z=[z(2:2*N);N-.5];x=x/max(x);y=y/max(y);')
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'Mask Help','This block maps a digital signal onto in-phase and quadratic components, which are outputs in the first and second output port respectively. The M-ary number must be M=2^K with integer K. The input symbol interval can be a two-element vector with the second element being offset. The default value offset is 0. The maximum amplitudes for the outputs are 1.')
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'Mask Entries','M\/td\/')
% Finished composite block ['Square-map',13,'QASK mod/QASK',13,'square-map'].
set_param([sys,'/',['Square-map',13,'QASK mod/QASK',13,'square-map']],...
'position',[50,53,130,97])
add_block('built-in/Outport',[sys,'/',['Square-map',13,'QASK mod/out_1']])
set_param([sys,'/',['Square-map',13,'QASK mod/out_1']],...
'position',[275,65,295,85])
add_block('built-in/Inport',[sys,'/',['Square-map',13,'QASK mod/in_1']])
set_param([sys,'/',['Square-map',13,'QASK mod/in_1']],...
'position',[5,65,20,85])
add_line([sys,'/',['Square-map',13,'QASK mod']],[135,65;160,65])
add_line([sys,'/',['Square-map',13,'QASK mod']],[135,85;160,85])
add_line([sys,'/',['Square-map',13,'QASK mod']],[250,75;270,75])
add_line([sys,'/',['Square-map',13,'QASK mod']],[25,75;45,75])
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'Mask Display','plot(0,0,100,100,x,y);S-QASK',...
'Mask Type','Passband S-QASK modulation')
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'Mask Dialogue','Modulate the input signal using\nquadrature amplitude shift keying\nmodulation method with square constellation.|M-ary number (input digits in range [0, M-1]):|Symbol interval (sec):|Carrier frequency (Hz):|Initial phase (rad):|Sample time (sec):')
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'Mask Translate','M=@1;td=@2;Fc=@3;Ph=@4;ts=@5;[x,y]=moduicon(5);')
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'Mask Help','This block modulates a digital signal using QASK method with square constellation. The inputs are integers in the range [0, M-1], where M is the M-ary number, which is M=2^K. K is an integer. When the symbol interval is a two element vector, the second element is the offset (default 0). ')
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'Mask Entries','M\/td\/100/2/pi\/0\/ts\/')
% Finished composite block ['Square-map',13,'QASK mod'].
set_param([sys,'/',['Square-map',13,'QASK mod']],...
'hide name',0,...
'position',[145,43,225,87])
% Subsystem ['Sampled read',13,'from wksp'].
new_system([sys,'/',['Sampled read',13,'from wksp']])
set_param([sys,'/',['Sampled read',13,'from wksp']],'Location',[355,528,737,675])
% Subsystem ['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1'].
new_system([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],'Location',[55,192,283,286])
add_block('built-in/S-Function',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/S-function1']],...
'function name','homopuls',...
'parameters','samp_time, out_divid, offset',...
'position',[40,31,105,59])
add_block('built-in/Outport',[sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1/Outport']],...
'position',[160,35,180,55])
add_line([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Display','Vector\nPulse',...
'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time ./Divider. |Sample time (scalar, sec):|Divider (integer vector):|Offset (have same dimension as Divider:')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Help','This block generator a vector pulses. The output length is the same as the vector defined in "Divider". The ith element of the output has the sample time Sample_time/Divider(i). All elements in "Divider" must be integers.')
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'Mask Entries','ts\/1\/off\/')
% Finished composite block ['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1'].
set_param([sys,'/',['Sampled read',13,'from wksp/Pulses deivide',13,'same sample time1']],...
'position',[50,56,110,94])
add_block('built-in/Outport',[sys,'/',['Sampled read',13,'from wksp/out_1']])
set_param([sys,'/',['Sampled read',13,'from wksp/out_1']],...
'position',[295,65,315,85])
add_block('built-in/S-Function',[sys,'/',['Sampled read',13,'from wksp/Message source']])
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
'BackGround',5,...
'function name','trigwksp',...
'parameters','var,thd,cyclFlag,ini',...
'Mask Display','Triggered\nread',...
'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
'Mask Dialogue','The raising edge of input pulse trigger the block output the next row from the workspace variable.|Read the variable:|Threshold for the input pulse:|Cyclic read variable (1) or amend zeros (0).|Output before first trigger:')
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;')
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
'Mask Help','This block reads the data from a workspace variable. The output is refreshed at the raising edge of the input pulse.',...
'Mask Entries','var\/.1\/cyc\/ini\/')
set_param([sys,'/',['Sampled read',13,'from wksp/Message source']],...
'position',[180,53,255,97])
add_line([sys,'/',['Sampled read',13,'from wksp']],[260,75;290,75])
add_line([sys,'/',['Sampled read',13,'from wksp']],[115,75;175,75])
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'Mask Display','plot(0,0,100,100,x,y);Rd wksp',...
'Mask Type','Read from workspace')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'Mask Dialogue','Read from a workspace variable at\nsampling time point.|Variable (column_number=block_output_length):|Data output sample time (sec):|Cyclic control (1: cyclic read, 0: output zeros after eof).|Initial output:')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'Mask Translate','var=@1;td=@2;ts=td(1);if (length(td)>=2),off=td(2);else off=0;end;cyc=@3;ini=@4;[x,y]=srcsicon(7);')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'Mask Help','This block reads from a workspace variable at a given sample time. The column number is the block output vector length. When the simulation reached the end of the variable (eof) row, the block will cyclically output from the first row of the variable or output zeros based on the cyclic control entree.')
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'Mask Entries','randint(300,1,M)\/td\/1\/0\/')
% Finished composite block ['Sampled read',13,'from wksp'].
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'hide name',0,...
'position',[35,43,110,87])
% 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\/.001\/12345\/')
% Finished composite block ['AWGN',13,'channel'].
set_param([sys,'/',['AWGN',13,'channel']],...
'hide name',0,...
'position',[275,43,355,87])
add_line(sys,[485,65;545,65])
add_line(sys,[115,65;140,65])
add_line(sys,[125,65;125,20;505,20;505,45;545,45])
add_line(sys,[230,65;270,65])
add_line(sys,[360,65;395,65])
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 + -