function sb2slmul(blkname,in,fl,st,cod,timer)
%SB2SLMUL converts multi-linear interpolation blocks to SIMULINK.
%	SB2SLMUL(BLKNAME,IN,FL,ST,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, real number
%	FL, and string ST.
%
%       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.

%2,2, multi-interpolation

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

blank = '                                                                  ';
blank = [blank '                                                          '];
blank = [blank '                                                          '];
st = setstr(st)';
indb = find(st == '|');
indp = find(st == ';');
tmp = 1;
while indb(tmp) < indp(1)
  tmp = tmp + 1;
end;
st = st(indb(tmp-1)+1:length(st));
indb = find(st == '|');
%st = st(1:indb(1)-1);
indp = find(st == ';');
if length(indp) ~= in(4)
  disp('There is some thing goes wrong in convertion, error code ssb2slmul')
  return;
end;
tmp = indp(length(indp));
output = st(tmp + 1: indb(1) -1);
st = st(1:tmp-1);
indp = find(st == ';');
st(indp) = blank(1:length(indp));
indp=[indp length(st)+1];
tmp = 1;
for i=1:in(4)
  inpidx = [inpidx 'length(' st(tmp:indp(i)-1) ') '];
  tmp = indp(i) + 1;
end;
inpidx = ['[' inpidx ']'];
st = ['[' st ']'];

%Subsystem 'Multi-Interpolation'

new_system([blkname '/Multi-Interpolation'])
set_param([blkname '/Multi-Interpolation'],'Location',[316,537,598,691])
add_block('built-in/Outport',[blkname,'/Multi-Interpolation/table out'])
set_param([blkname,'/Multi-Interpolation/table out'],...
	'position',[215,55,235,75])
add_block('built-in/Inport',[blkname,'/Multi-Interpolation/x0'])
set_param([blkname,'/Multi-Interpolation/x0'],...
	'position',[20,55,40,75])
add_block('built-in/S-function',[blkname,'/Multi-Interpolation/S-function'])
set_param([blkname,'/Multi-Interpolation/S-function'],...
	'function name','multlinr',...
	'parameters','input, inpidx, table',...
	'position',[95,50,145,80])
add_line([blkname,'/Multi-Interpolation'],[150,65;205,65])
add_line([blkname,'/Multi-Interpolation'],[45,65;85,65])
set_param([blkname,'/Multi-Interpolation'],'Mask Display',...
	'plot(-10,-10,110,110,[50,50,100],[100,50,50],[47,50,53],[90,100,90],[90,100,90],[45,50,55],[50,5,10,5,13],[50,5,17,5,7],[5,25,45,75,100,80,60,30,5],[20,60,80,80,70,60,20,35,20])')
set_param([blkname,'/Multi-Interpolation'],...
	'Mask Type','Multi-Dimensional Interpolation')
set_param([blkname,'/Multi-Interpolation'],'Mask Dialogue',...
	'Multi-Dimensional Interpolator.|Input index vectors:|Dimension of index vector:|Gain vector:')
set_param([blkname,'/Multi-Interpolation'],'Mask Translate',...
	'input=@1;inpidx=@2;table=@3;multlchk(input,inpidx,table);')
set_param([blkname,'/Multi-Interpolation'],'Mask Help',...
	'If the Input index vector is [x1(1)...x1(n1) x2(1)...x2(n2) ... xk(1)...xk(nk)] the Dimension information will be [n1 n2 ... nk].  The Gain vector''s first element should be the value associated with {x1(1),x2(1),...,xk(1)}, its second element with {x1(1),x2(1),...,xk(2)}, etc. Note: length(Input index vector)=sum(Dimension of index vectors) and length(Gain table)=prod(Dimension of index vectors).');
set_param([blkname,'/Multi-Interpolation'],'Mask Entries',...
	[st '\/' inpidx '\/' output '\/'])
%finished 'multi-interpolation' block

add_block('built-in/Mux',[blkname,'/Mux'])
set_param([blkname,'/Mux'],...
		'inputs',num2str(in(4)),...
		'position',[150,50,180,60+10*in(4)])
set_param([blkname,'/Multi-Interpolation'],...
		'position',[235,5*in(4)+15,350,5*in(4)+85])
add_line(blkname,'Mux/1','Multi-Interpolation/1')
set_param([blkname '/output1'],'position',[420,5*in(4)+40,440,5*in(4)+60])
add_line(blkname,'Multi-Interpolation/1','output1/1')
for i=1:in(4)
  set_param([blkname '/input' num2str(i)],'position',...
	[30+30*rem(i,2),35+10*i,50+30*rem(i,2),55+10*i])
  autoline(blkname,['input' num2str(i) '/1'],['Mux/' num2str(i)]);
end;
set_param(blkname,'Mask Display',...
	'plot(-10,-10,110,110,[50,50,100],[100,50,50],[47,50,53],[90,100,90],[90,100,90],[45,50,55],[50,95,90,95,87],[50,95,83,95,94],[5,25,45,75,100,80,60,30,5],[20,60,80,80,70,60,20,35,20])')
