⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tstlinco.m

📁 通信系统的matlab仿真程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function [ret,x0,str,ts,xts]=tstlinco(t,x,u,flag);
%TSTLINCO	is the M-file description of the SIMULINK system named TSTLINCO.
%	The block-diagram can be displayed by typing: TSTLINCO.
%
%	SYS=TSTLINCO(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 TSTLINCO 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 TSTLINCO with a FLAG of zero:
%	[SIZES]=TSTLINCO([],[],[],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',[34,127,848,267])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '999999')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Scope',[sys,'/','Error-added'])
set_param([sys,'/','Error-added'],...
		'hide name',0,...
		'Vgain','1.500000',...
		'Hgain','5.000000',...
		'Vmax','3.000000',...
		'Hmax','10.000000',...
		'Window',[367,288,813,556])
open_system([sys,'/','Error-added'])
set_param([sys,'/','Error-added'],...
		'position',[540,97,560,123])

add_block('built-in/Sum',[sys,'/','Sum'])
set_param([sys,'/','Sum'],...
		'hide name',0,...
		'inputs','+',...
		'position',[475,100,495,120])

add_block('built-in/S-Function',[sys,'/',['Integer vector',13,'to scalar']])
set_param([sys,'/',['Integer vector',13,'to scalar']],...
		'hide name',0,...
		'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',[585,43,665,87])


%     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','4\/20\/0\/1\/')


%     Finished composite block 'Error rate1'.

set_param([sys,'/','Error rate1'],...
		'hide name',0,...
		'position',[695,18,775,62])


%     Subsystem  ['Max-err lmtd',13,'b-err channel'].

new_system([sys,'/',['Max-err lmtd',13,'b-err channel']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],'Location',[124,322,430,428])

add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/out_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/out_1']],...
		'hide name',0,...
		'position',[275,20,295,40])

add_block('built-in/S-Function',[sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
		'hide name',0,...
		'function name','arymodu',...
		'parameters','md',...
		'Mask Display','Modulo',...
		'Mask Type','Modulo')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
		'Mask Dialogue','Modulus operation:|Modulus base:',...
		'Mask Translate','md = @1;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
		'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/Mdu']],...
		'Mask Entries','2\/',...
		'position',[195,11,255,49])

add_block('built-in/Sum',[sys,'/',['Max-err lmtd',13,'b-err channel/S']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/S']],...
		'hide name',0,...
		'position',[150,20,170,40])

add_block('built-in/Inport',[sys,'/',['Max-err lmtd',13,'b-err channel/in_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/in_1']],...
		'hide name',0,...
		'position',[40,5,60,25])

add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/out_2']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/out_2']],...
		'hide name',0,...
		'Port','2',...
		'position',[275,50,295,70])


%     Subsystem  ['Max-err lmtd',13,'b-err channel/B-n'].

new_system([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],'Location',[36,445,326,560])

add_block('built-in/S-Function',[sys,'/',['Max-err lmtd',13,'b-err channel/B-n/S-function']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n/S-function']],...
		'function name','srandbit',...
		'parameters','n, prob, seed',...
		'position',[90,35,140,55])

add_block('built-in/Outport',[sys,'/',['Max-err lmtd',13,'b-err channel/B-n/out_1']])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n/out_1']],...
		'position',[190,35,210,55])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],[145,45;185,45])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'Mask Display','B-vector\ngenerator',...
		'Mask Type','Binary noise generator')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'Mask Dialogue','Generate a binary vector with the probability of "1"s in the vector being specified.|Vector length(can''t be changed during simulation):|Probability of a "one", two "ones",three "ones"...:|Seed:')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'Mask Translate','n=@1;prob=@2;seed=@3;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'Mask Help','This block outputs a zero vector with "1"s randomly distributed the vector. The maximum number of "1"s in the vector is the same as the length of the vector probability. The value of ith element of the probability is the probability of i number of "1"s in the vector.')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'Mask Entries','leng\/prob\/seed\/')


%     Finished composite block ['Max-err lmtd',13,'b-err channel/B-n'].

set_param([sys,'/',['Max-err lmtd',13,'b-err channel/B-n']],...
		'hide name',0,...
		'position',[30,38,110,82])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[175,30;190,30])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[260,30;270,30])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[115,60;130,60;130,35;145,35])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[115,60;270,60])
add_line([sys,'/',['Max-err lmtd',13,'b-err channel']],[65,15;90,15;90,25;145,25])
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'Mask Display','plot(0,0,100,100,x,y);Lmtd b-err',...
		'Mask Type','Limited binary error channel')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'Mask Dialogue','Add binary errors with specified error\nnumber probability.|Vector length(can''t be changed during simulation):|Probability of one err, two errs, three errs...:|Seed:')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'Mask Translate','leng=@1;prob=@2;seed=@3;[x,y]=chanicon;')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'Mask Help','This block adds binary errors to the input signal. The maximum number of errors added to the signal is the same as the length of the vector probability. The value of ith element of the probability is the probability of i number of errors in the vector. The 1st outport is the signal with added noise. The 2nd outport is the added noise.')
set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'Mask Entries','7\/1/2\/12345\/')


%     Finished composite block ['Max-err lmtd',13,'b-err channel'].

set_param([sys,'/',['Max-err lmtd',13,'b-err channel']],...
		'hide name',0,...
		'position',[360,53,440,97])


%     Subsystem  ['Random-integer',13,'generator1'].

new_system([sys,'/',['Random-integer',13,'generator1']])
set_param([sys,'/',['Random-integer',13,'generator1']],'Location',[98,518,454,687])

add_block('built-in/S-Function',[sys,'/',['Random-integer',13,'generator1/Uniform',13,'number']])
set_param([sys,'/',['Random-integer',13,'generator1/Uniform',13,'number']],...
		'function name','srandint',...
		'parameters','seed,mul',...
		'position',[65,45,135,85])

add_block('built-in/Outport',[sys,'/',['Random-integer',13,'generator1/out_1']])
set_param([sys,'/',['Random-integer',13,'generator1/out_1']],...
		'position',[165,55,185,75])
add_line([sys,'/',['Random-integer',13,'generator1']],[140,65;160,65])
set_param([sys,'/',['Random-integer',13,'generator1']],...
		'Mask Display','plot(0,0,100,100,x,y);Random int',...
		'Mask Type','Random integer generator')
set_param([sys,'/',['Random-integer',13,'generator1']],...
		'Mask Dialogue','Generate integers randomly distributed in range [0, M-1], where M is the M-ary number.|M-ary number:|Seed:')
set_param([sys,'/',['Random-integer',13,'generator1']],...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -