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

📄 sb2sllit.m

📁 数字通信第四版原书的例程
💻 M
字号:
function sb2sllit(blkname,in,fl,cod,timer)
%SB2SLLIT converts linear interpolation tables to SIMULINK.
%	SB2SLLIT(BLKNAME,IN,FL,COD,TIMER) converts a SystemBuild block
%       to a SIMULINK block.  BLKNAME is a string containing the name of
%       the block. The parameters are set up for this block based on the
%       SystemBuild file coding integer IN and real number FL.
%
%       COD is a three dimensional vector. The first element indicates
%       whether it is a continuous (0) or discrete (1) time system.
%       The second element indicates whether it does not need (0) or
%       does need (1) a mask. The third element indicates the
%       orientation of the block.
%
%       TIMER is designed for discrete time only. The first element of
%       TIMER is the sampling time. The second element is the initial time.

% Wes Wang 10/2/92 -- 10/6/92
% Copyright (c) 1990-93 by The MathWorks, Inc.
% $Revision: 1.13 $  $Date: 1993/06/09 22:09:40 $

temp = in(in(17)+3);
if in(3) == 6
  temp = in(in(17)+4);
end;
[tmp1,ind] = sort(fl(1:temp)');
if in(4) > 1 | in(5) == 1
  tmp2(1,:) = fl(temp+1:2*temp)';
else
  for j = 1:in(5)
    for i = 1:length(tmp1)
      temp = temp + 1;
      tmp2(j,i) = fl(temp);
    end;
  end;
end;
tmp2 = tmp2(:,ind);
x = mat2str(tmp1); y = mat2str(tmp2);
if length(x) >= 255 | length(y) >= 255
  load sb2sltmp
  app = sb2slbnm(blkname);
  x = ['O' num2str(xn+1) app]; y = ['O' num2str(xn+2) app]; 
  eval([x '= tmp1;']);
  appsave('sb2sltmp', x, tmp1);
  disp([x ' is used as index of look up table in ' blkname])
  eval([y '= tmp2;']);
  appsave('sb2sltmp', y, tmp2);
  disp([y ' is used as table content of look up table in ' blkname])
  % xs=[xs x y];
  xn=xn+2;
  appsave('sb2sltmp', 'xn', xn);
  % eval(xs)
end;
if in(4) == 1
  if in(5) ==1
    %simply add a parameter in
    set_param(blkname,'Input_Values',x,...
              'Output_Values',y);
  else
    %in------>look_up_table_1----->output1
    %    |
    %    |--->look_up_table_2----->output2
    %    |
    %    |--->look_up_table_3----->output3
    set_param([blkname '/input1'],...
	'position',[45,25+20,65,25+40]);
    for i=1:in(5), 
      add_block('built-in/Look Up Table',[blkname '/LUT' num2str(i)])
      set_param([blkname '/LUT' num2str(i)],'Input_Values','x',...
              'Output_Values',['y(' num2str(i) ',:)'],...
              'position',[160,75*i-50,275,75*i-10]);
      autoline(blkname,'input1/1',['LUT' num2str(i) '/1']);
      set_param([blkname '/output' num2str(i)],'Port',num2str(i),...
  	      'position',[380,75*i-40,400,75*i-20]);
      autoline(blkname,['LUT' num2str(i) '/1'],['output' num2str(i) '/1']);
    end
  end
else
  %in the case of MIMO, no_input == no_output
  add_block('built-in/Look Up Table',[blkname '/LUT'])
  set_param([blkname '/LUT'],'Input_Values','x',...
        'Output_Values','y', ...
        'position',[200,45,275,85]);
  add_block('built-in/Mux',[blkname '/Mux'])
  set_param([blkname '/Mux'],...
	'inputs',num2str(in(4)),...
	'position',[135,45,165,65+10*in(4)])
  autoline(blkname, 'Mux/1', 'LUT/1');
  add_block('built-in/Demux',[blkname '/Demux'])
  set_param([blkname '/Demux'],...
	'outputs',num2str(in(5)),...
	'position',[300,45,340,65+10*in(5)])
  tmp = get_param([blkname '/Demux'],'position');
  set_param([blkname '/Demux'],'position',tmp);
  autoline(blkname, 'LUT/1', 'Demux/1');
  for i=1:in(4), 
    set_param([blkname '/input' num2str(i)],...
	'position',[45-30*rem(i,2),25*i+20,65-30*rem(i,2),25*i+40],...
	'Port', num2str(i));
    set_param([blkname '/output' num2str(i)],...
	'position',[375+30*rem(i,2),25*i+20,395+30*rem(i,2),25*i+40],...
	'Port', num2str(i));
    autoline(blkname,['input' num2str(i) '/1'],['Mux/' num2str(i)]);
    autoline(blkname,['Demux/' num2str(i)],['output' num2str(i) '/1']);
  end;
end
if in(5) > 1
  set_param(blkname,'Mask Display',...
    'Look Up\nTable',...
    'Mask Type','Look Up Table',...
    'Mask Dialogue','Look Up Table|X axis:|Table:')
  temp = 'For Input x, the ith output will be the linear interpolation of';
  temp = [temp ' [x, y(i,:)] into the lookup table'];
  set_param(blkname,'Mask Translate','x=@1;y=@2',...
    'Mask Help',temp);
  set_param(blkname,'Mask Entries',[x '\/' y '\/'])
end;



⌨️ 快捷键说明

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