function sb2slcoo(blkname,in)
%SB2SLCOO converts the axis coordinate change block to SIMULINK.
%	SB2SLCOO(BLKNAME,IN) converts a SystemBuild block to SIMULINK
%	block. BLKNAME is a string containing the name of the block. The 
%	parameters are set up based on SystemBuild file coding integer IN.

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

pmi = in(in(17)+3:in(17)+5)';
name = ['x' 'y' 'z'];
done=[1 1 1];
for i=1:4
  if sum(done) > 0
    if i <=3 
      done(pmi(i)) = 0;
      j = pmi(i);
    else
      j = find(done ~= 0);
    end
    na = [name(j) '-axis-rotation' num2str(i)];
    tpname=[tpname; na];
    na = [blkname '/' na];
    na_st = [na_st; na];
    new_system(na);
    set_param(na,'Location',[31,118,689,385])
    % begin the detail layout
    % j = 1 then i/o ==> 1 2 3
    % j = 2 then i/o ==> 2 3 1
    % j = 3 then i/o ==> 3 1 2
    if j == 1
       io = ['1' '2' '3'];
    elseif j == 2
       io = ['2' '3' '1'];
    else
       io = ['3' '1' '2'];
    end;
    add_block('built-in/Inport',[na '/Inport' io(1)])
    set_param([na '/Inport' io(1)],...
	'Port',io(1),...
	'position',[55,40,75,60])
    add_block('built-in/Inport',[na '/Inport' io(2)])
    set_param([na '/Inport' io(2)],...
	'Port',io(2),...
	'position',[55,80,75,100])
    add_block('built-in/Inport',[na '/Inport' io(3)])
    set_param([na '/Inport' io(3)],...
	'Port',io(3),...
	'position',[95,105,115,125])
    add_block('built-in/Inport',[na '/Inport4'])
    set_param([na '/Inport4'],...
	'Port','4',...
	'position',[55,150,75,170])
    add_block('built-in/Outport',[na '/Outport' io(1)])
    set_param([na '/Outport' io(1)],...
	'Port',io(1),...
	'position',[485,40,505,60])
    add_block('built-in/Outport',[na '/Outport' io(2)])
    set_param([na '/Outport' io(2)],...
	'Port',io(2),...
	'position',[465,90,485,110])
    add_block('built-in/Outport',[na '/Outport' io(3)])
    set_param([na '/Outport' io(3)],...
	'Port',io(3),...
	'position',[465,145,485,165])
    add_block('built-in/Mux',[na '/Mux'])
    set_param([na '/Mux'],...
	'position',[240,78,265,177])
    add_block('built-in/Fcn',[na '/Fcn2'])
    if in(3) == 5
      temp1 = 'u[1]*u[3]+u[2]*u[4]';
      temp2 = 'u[2]*u[3]-u[1]*u[4]';
    else
      temp1 = 'u[1]*u[3]-u[2]*u[4]';
      temp2 = 'u[2]*u[3]+u[1]*u[4]';
    end;
    set_param([na '/Fcn2'],...
	'Expr',temp1,...
	'position',[310,85,420,115])
    add_block('built-in/Fcn',[na '/Fcn3'])
    set_param([na '/Fcn3'],...
	'Expr',temp2,...
	'position',[310,141,430,169])
    add_block('built-in/Fcn',[na '/Fcn'])
    set_param([na '/Fcn'],...
	'Expr','cos(u[1])',...
	'position',[140,128,190,152])
    add_block('built-in/Fcn',[na '/Fcn1'])
    set_param([na '/Fcn1'],...
	'position',[115,168,165,192])
    autoline(na,['Inport' io(1) '/1'],['Outport',io(1) '/1']);
    autoline(na,['Inport',io(2) '/1'],['Mux/1']);
    autoline(na,['Inport',io(3) '/1'],['Mux/2']);
    autoline(na,['Inport4/1'],['Fcn/1']);
    autoline(na,['Inport4/1'],['Fcn1/1']);
    autoline(na,['Fcn/1'],'Mux/3');
    autoline(na,['Fcn1/1'],'Mux/4');
    autoline(na,'Mux/1','Fcn2/1');
    autoline(na,'Mux/1','Fcn3/1');
    autoline(na,'Fcn2/1',['Outport' io(2) '/1']);
    autoline(na,'Fcn3/1',['Outport' io(3) '/1']);
    set_param(na,...
	'Mask Display',[name(j) '-axis\nrotation'])
    % end the detail layout
  end
end
[j,i]=size(na);
if in(3) == 5
  k=[3 2 1];
  tile = 'axis rotation with combination ';
  set_param(blkname,'Mask Display','Axis\nRotation')
else
  k = [1 2 3];
  tile = 'axis inverse rotation with combination ';
  set_param(blkname,'Mask Display','Axis\nInverse\nRotation')
end;
tile = [tile,name(pmi(1)),name(pmi(2)),name(pmi(3)),' or ',...
	mat2str([pmi(1),pmi(2) pmi(3)])];
%write the title
add_block('built-in/Note',[blkname '/' tile])
set_param([blkname '/' tile],'position',[310,20,311,21])
set_param(na_st(k(1),:),'position',[140,44,200,101])
set_param(na_st(k(2),:),'position',[280,49,340,106])
set_param(na_st(k(3),:),'position',[425,54,485,111])
if j > 3
  set_param(na_st(4,:),'position',[265,164,325,221])
end;
set_param([blkname,'/input1'],...
		'position',[20,40,40,60])
set_param([blkname,'/input2'],'Port','2',...
		'position',[55,55,75,75])
set_param([blkname '/input3'],'Port','3',...
		'position',[90,70,110,90])
set_param([blkname,'/input4'],'Port','4',...
		'position',[20,85,40,105])
set_param([blkname '/input5'],'Port','5',...
		'position',[45,110,65,130])
set_param([blkname,'/input6'],'Port','6',...
		'position',[85,130,105,150])
set_param([blkname,'/output1'],...
		'position',[575,55,595,75])
set_param([blkname '/output2'],'Port','2',...
		'position',[545,75,565,95])
set_param([blkname, '/output3'],'Port','3',...
		'position',[520,95,540,115])
autoline(blkname,'input1/1',[tpname(k(1),:) '/1']);
autoline(blkname,'input2/1',[tpname(k(1),:) '/2']);
autoline(blkname,'input3/1',[tpname(k(1),:) '/3']);
autoline(blkname,'input4/1',[tpname(k(1),:) '/4']);
autoline(blkname,'input5/1',[tpname(k(2),:) '/4']);
autoline(blkname,'input6/1',[tpname(k(3),:) '/4']);
autoline(blkname,[tpname(k(1),:) '/1'],[tpname(k(2),:) '/1']);
autoline(blkname,[tpname(k(1),:) '/2'],[tpname(k(2),:) '/2']);
autoline(blkname,[tpname(k(1),:) '/3'],[tpname(k(2),:) '/3']);
autoline(blkname,[tpname(k(2),:) '/1'],[tpname(k(3),:) '/1']);
autoline(blkname,[tpname(k(2),:) '/2'],[tpname(k(3),:) '/2']);
autoline(blkname,[tpname(k(2),:) '/3'],[tpname(k(3),:) '/3']);
autoline(blkname,[tpname(k(3),:) '/1'],'output1/1');
autoline(blkname,[tpname(k(3),:) '/2'],'output2/1');
autoline(blkname,[tpname(k(3),:) '/3'],'output3/1');
