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

📄 com_mux.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [ret,x0,str,ts,xts]=com_mux(t,x,u,flag);
%COM_MUX       is the M-file description of the SIMULINK system named COM_MUX.
%        The block-diagram can be displayed by typing: COM_MUX.
%
%        SYS=COM_MUX(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 COM_MUX 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 COM_MUX with a FLAG of zero:
%   [SIZES]=COM_MUX([],[],[],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.
%     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.2)
if (0 == (nargin + nargout))
     set_param(sys,'Location',[72,98,572,398])
     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',   '')


%     Subsystem  'MAPC mux'.

new_system([sys,'/','MAPC mux'])
set_param([sys,'/','MAPC mux'],'Location',[291,328,907,586])

add_block('built-in/Inport',[sys,'/','MAPC mux/in_3'])
set_param([sys,'/','MAPC mux/in_3'],...
              'Port','3',...
          'position',[40,205,60,225])

add_block('built-in/Inport',[sys,'/','MAPC mux/in_2'])
set_param([sys,'/','MAPC mux/in_2'],...
                'Port','2',...
          'position',[40,175,60,195])

add_block('built-in/Inport',[sys,'/','MAPC mux/in_1'])
set_param([sys,'/','MAPC mux/in_1'],...
                'position',[35,135,55,155])

add_block('built-in/Outport',[sys,'/','MAPC mux/out_1'])
set_param([sys,'/','MAPC mux/out_1'],...
             'position',[505,145,525,165])
add_line([sys,'/','MAPC mux'],[60,145;275,145;275,155;500,155])
set_param([sys,'/','MAPC mux'],...
          'Mask Display','MAPC\nmux',...
          'Mask Type','MAPC',...
          'Mask Dialogue','Multiple Access per Channel:|Number of Channels',...
           'Mask Translate','need a better user interface/')
set_param([sys,'/','MAPC mux'],...
             'Mask Help','This block may need a better user interface. Function of trhis block is to select the correct input from the indication of the last port. The block outputs the selected input number to output.')
set_param([sys,'/','MAPC mux'],...
               'Mask Entries','\/')


%     Finished composite block 'MAPC mux'.

set_param([sys,'/','MAPC mux'],...
                'position',[260,45,310,95])

add_block('built-in/Constant',[sys,'/',['Request',13,'for ch 1']])
set_param([sys,'/',['Request',13,'for ch 1']],...
          'position',[25,115,45,135])

add_block('built-in/Constant',[sys,'/','Infor of Ch2'])
set_param([sys,'/','Infor of Ch2'],...
                'Value','2',...
         'position',[130,60,150,80])

add_block('built-in/Constant',[sys,'/','Infor of Ch1'])
set_param([sys,'/','Infor of Ch1'],...
                'position',[75,45,95,65])


%     Subsystem  ['Multi-access',13,'distrobutor'].

new_system([sys,'/',['Multi-access',13,'distrobutor']])
set_param([sys,'/',['Multi-access',13,'distrobutor']],'Location',[488,471,776,628])

add_block('built-in/Outport',[sys,'/',['Multi-access',13,'distrobutor/out_1']])
set_param([sys,'/',['Multi-access',13,'distrobutor/out_1']],...
            'position',[230,20,250,40])

add_block('built-in/Inport',[sys,'/',['Multi-access',13,'distrobutor/in_2']])
set_param([sys,'/',['Multi-access',13,'distrobutor/in_2']],...
          'Port','2',...
          'position',[35,75,55,95])

add_block('built-in/Inport',[sys,'/',['Multi-access',13,'distrobutor/in_1']])
set_param([sys,'/',['Multi-access',13,'distrobutor/in_1']],...
            'position',[35,20,55,40])
add_line([sys,'/',['Multi-access',13,'distrobutor']],[60,30;225,30])
set_param([sys,'/',['Multi-access',13,'distrobutor']],...
          'Mask Display','Multi-access\ndistributor',...
          'Mask Type','Traffic control block',...
         'Mask Dialogue','Traffic control block:|Number of inputs:',...
          'Mask Translate','ni=@1;')
set_param([sys,'/',['Multi-access',13,'distrobutor']],...
             'Mask Help','The Multi-access dittributor block manages the channel access previllage. An channel requests for accessing previllege by providing an one at the given input number. The distributor assign the channel number to the first output.')
set_param([sys,'/',['Multi-access',13,'distrobutor']],...
            'Mask Entries','3\/')


%     Finished composite block ['Multi-access',13,'distrobutor'].

set_param([sys,'/',['Multi-access',13,'distrobutor']],...
         'position',[120,109,200,171])

add_block('built-in/Constant',[sys,'/',['Request',13,'for ch 2']])
set_param([sys,'/',['Request',13,'for ch 2']],...
                'Value','2',...
         'position',[65,145,85,165])


%     Subsystem  'MAPC demux'.

new_system([sys,'/','MAPC demux'])
set_param([sys,'/','MAPC demux'],'Location',[291,328,907,586])

add_block('built-in/Outport',[sys,'/','MAPC demux/out_2'])
set_param([sys,'/','MAPC demux/out_2'],...
           'Port','2',...
          'position',[500,185,520,205])

add_block('built-in/Outport',[sys,'/','MAPC demux/out_1'])
set_param([sys,'/','MAPC demux/out_1'],...
               'position',[505,145,525,165])

add_block('built-in/Inport',[sys,'/','MAPC demux/in_1'])
set_param([sys,'/','MAPC demux/in_1'],...
          'position',[35,135,55,155])

add_block('built-in/Inport',[sys,'/','MAPC demux/in_2'])
set_param([sys,'/','MAPC demux/in_2'],...
            'Port','2',...
          'position',[40,175,60,195])
add_line([sys,'/','MAPC demux'],[60,145;275,145;275,155;500,155])
set_param([sys,'/','MAPC demux'],...
                'Mask Display','MAPC\ndemux',...
                'Mask Type','MAPC',...
          'Mask Dialogue','Multiple Access per Channel:|Number of Channels',...
           'Mask Translate','need a better user interface/')
set_param([sys,'/','MAPC demux'],...
           'Mask Help','This block may need a better user interface. Function of trhis block is to select the correct input from the indication of the last port. The block outputs the selected input number to output.')
set_param([sys,'/','MAPC demux'],...
             'Mask Entries','\/')


%     Finished composite block 'MAPC demux'.

set_param([sys,'/','MAPC demux'],...
            'orientation',2,...
             'position',[330,212,380,263])
add_line(sys,[205,140;225,140;225,85;255,85])
add_line(sys,[315,70;405,70;405,225;385,225])
add_line(sys,[225,140;395,140;385,250])
add_line(sys,[50,125;115,125])
add_line(sys,[90,155;115,155])
add_line(sys,[100,55;255,55])
add_line(sys,[155,70;255,70])

% 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
end

⌨️ 快捷键说明

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