📄 tmpfs2cd.m
字号:
function [ret,x0,str,ts,xts]=tmpfs2cd(t,x,u,flag);
%TMPFS2CD is the M-file description of the SIMULINK system named TMPFS2CD.
% The block-diagram can be displayed by typing: TMPFS2CD.
%
% SYS=TMPFS2CD(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 TMPFS2CD 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 TMPFS2CD with a FLAG of zero:
% [SIZES]=TMPFS2CD([],[],[],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',[29,84,821,393])
open_system(sys)
end;
set_param(sys,'algorithm', 'RK-45')
set_param(sys,'Start time', '0.0')
set_param(sys,'Stop time', '999')
set_param(sys,'Min step size', 'ts')
set_param(sys,'Max step size', 'ts')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars', '')
set_param(sys,'Load callback','ts=.01;td=.2;M=8;Fc=100/2/pi;');
% 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])
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_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])
% 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/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_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_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_line([sys,'/',['Sampled read',13,'from wksp']],[115,75;175,75])
add_line([sys,'/',['Sampled read',13,'from wksp']],[260,75;290,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','[0:M-1]''\/td\/1\/0\/')
% Finished composite block ['Sampled read',13,'from wksp'].
set_param([sys,'/',['Sampled read',13,'from wksp']],...
'hide name',0,...
'position',[20,63,95,107])
% Subsystem 'Error rate1'.
new_system([sys,'/','Error rate1'])
set_param([sys,'/','Error rate1'],'Location',[255,368,509,510])
add_block('built-in/Inport',[sys,'/','Error rate1/in_2'])
set_param([sys,'/','Error rate1/in_2'],...
'Port','2',...
'position',[15,60,35,80])
add_block('built-in/Inport',[sys,'/','Error rate1/in_1'])
set_param([sys,'/','Error rate1/in_1'],...
'position',[15,45,35,65])
add_block('built-in/Mux',[sys,'/','Error rate1/Mux'])
set_param([sys,'/','Error rate1/Mux'],...
'inputs','2',...
'position',[65,46,100,79])
add_block('built-in/S-Function',[sys,'/','Error rate1/S-function'])
set_param([sys,'/','Error rate1/S-function'],...
'function name','sbiterr',...
'parameters','num_lin, K, TDelay, Sample',...
'position',[130,52,195,78])
add_line([sys,'/','Error rate1'],[40,70;60,70])
add_line([sys,'/','Error rate1'],[40,55;60,55])
add_line([sys,'/','Error rate1'],[105,65;125,65])
set_param([sys,'/','Error rate1'],...
'Mask Display','Error\nmeter',...
'Mask Type','Symbol/bit error counter')
set_param([sys,'/','Error rate1'],...
'Mask Dialogue','Use the input data from the 1st port as the reference signal to detect the number of errors and error rate of the 2nd port inputted signal.|Bit per symbol:|Number of digits on display:|Delay between input (1st port) and output (2nd port):|Sampling time (sec):')
set_param([sys,'/','Error rate1'],...
'Mask Translate','K=@1;num_lin=@2;TDelay=@3;Sample=@4;')
set_param([sys,'/','Error rate1'],...
'Mask Help','The signal from the first port must be a scalar. The second input port can be a vector with a same-time delay to the input signal. The comparison happens only at the sampling point.')
set_param([sys,'/','Error rate1'],...
'Mask Entries','3\/20\/td\/td\/')
% Finished composite block 'Error rate1'.
set_param([sys,'/','Error rate1'],...
'hide name',0,...
'position',[700,68,780,112])
% Subsystem 'M-FSK modulation'.
new_system([sys,'/','M-FSK modulation'])
set_param([sys,'/','M-FSK modulation'],'Location',[657,455,963,648])
set_param([sys,'/','M-FSK modulation'],...
'Mask Display','.',...
'Mask Dialogue',' ')
% Finished composite block 'M-FSK modulation'.
set_param([sys,'/','M-FSK modulation'],...
'ForeGround',3,...
'position',[125,50,320,121])
% Subsystem 'MFSK map'.
new_system([sys,'/','MFSK map'])
set_param([sys,'/','MFSK map'],'Location',[90,420,407,543])
add_block('built-in/Inport',[sys,'/','MFSK map/in_1'])
set_param([sys,'/','MFSK map/in_1'],...
'position',[45,45,65,65])
add_block('built-in/Gain',[sys,'/','MFSK map/Gain'])
set_param([sys,'/','MFSK map/Gain'],...
'Gain','Ton',...
'position',[175,38,225,72])
add_block('built-in/Outport',[sys,'/','MFSK map/out_1'])
set_param([sys,'/','MFSK map/out_1'],...
'position',[260,45,280,65])
add_block('built-in/Zero-Order Hold',[sys,'/',['MFSK map/Zero-Order',13,'Hold1']])
set_param([sys,'/',['MFSK map/Zero-Order',13,'Hold1']],...
'Sample time','td',...
'position',[105,39,140,71])
add_line([sys,'/','MFSK map'],[230,55;255,55])
add_line([sys,'/','MFSK map'],[70,55;100,55])
add_line([sys,'/','MFSK map'],[145,55;170,55])
set_param([sys,'/','MFSK map'],...
'Mask Display','MFSK\nmap',...
'Mask Type','MFSK map')
set_param([sys,'/','MFSK map'],...
'Mask Dialogue','Map input digital signal to analog tone space for FM modulation. The tone space\nis the frequency distance between two \nconsective digit numbers.|Tone space (Hz):|Input symbol interval and offset (sec):')
set_param([sys,'/','MFSK map'],...
'Mask Translate','Ton=@1;td=@2;')
set_param([sys,'/','MFSK map'],...
'Mask Help','This block maps the input digital signal to the analog signal, which is ready for the FM modulation. The input are integers in the range [0, M-1], where M is the M-ary number. Tone space is the frequency separation between two consective digits for the input signal. After FM, the modulated signal has a frequency in the range of [Fc, Fc+B]. B is the bandwidth of the FSK, B=(M-1) * Tone_space.')
set_param([sys,'/','MFSK map'],...
'Mask Entries','M/td/5\/td\/')
% Finished composite block 'MFSK map'.
set_param([sys,'/','MFSK map'],...
'hide name',0,...
'position',[135,63,215,107])
% Subsystem 'M-FSK coherent demodulation'.
new_system([sys,'/','M-FSK coherent demodulation'])
set_param([sys,'/','M-FSK coherent demodulation'],'Location',[657,455,963,648])
set_param([sys,'/','M-FSK coherent demodulation'],...
'Mask Display','.',...
'Mask Dialogue',' ')
% Finished composite block 'M-FSK coherent demodulation'.
set_param([sys,'/','M-FSK coherent demodulation'],...
'ForeGround',3,...
'position',[355,55,580,126])
add_block('built-in/Mux',[sys,'/','Mux'])
set_param([sys,'/','Mux'],...
'hide name',0,...
'inputs','2',...
'position',[625,72,660,123])
% Subsystem 'Min//max index'.
new_system([sys,'/','Min//max index'])
set_param([sys,'/','Min//max index'],'Location',[192,461,623,564])
add_block('built-in/S-Function',[sys,'/','Min//max index/Maximum'])
set_param([sys,'/','Min//max index/Maximum'],...
'function name','arymimai',...
'parameters','mima',...
'position',[240,20,320,40])
add_block('built-in/Outport',[sys,'/','Min//max index/out_1'])
set_param([sys,'/','Min//max index/out_1'],...
'position',[335,20,355,40])
add_block('built-in/Zero-Order Hold',[sys,'/',['Min//max index/Zero-Order',13,'Hold']])
set_param([sys,'/',['Min//max index/Zero-Order',13,'Hold']],...
'Sample time','td',...
'position',[165,14,200,46])
add_block('built-in/Inport',[sys,'/','Min//max index/in_1'])
set_param([sys,'/','Min//max index/in_1'],...
'position',[65,20,85,40])
add_line([sys,'/','Min//max index'],[205,30;235,30])
add_line([sys,'/','Min//max index'],[325,30;330,30])
add_line([sys,'/','Min//max index'],[90,30;160,30])
set_param([sys,'/','Min//max index'],...
'Mask Display','Min/Max\ndemap',...
'Mask Type','Maximum/minimum index.')
set_param([sys,'/','Min//max index'],...
'Mask Dialogue','Choose the index of the input vector with\nmax/min value at sampling point. Hold the\nvalue for the rest of the period.|Symbol interval (sec):|''max'' or ''min'':')
set_param([sys,'/','Min//max index'],...
'Mask Translate','td=@1;mima=@2;')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -