Home > classes > @ssm > cell_fusion.m

cell_fusion

PURPOSE ^

fusions a block defined matrix stored inside cell array into one matrix

SYNOPSIS ^

function a_out = cell_fusion(a, rowsizes, colsizes)

DESCRIPTION ^

 fusions a block defined matrix stored inside cell array into one matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: cell_fusion fusions a block defined matrix stored inside cell
 array into one matrix

 CALL: [mat3] = ssm.cell_fusion(cell1, rowsizes, colsizes)

 INPUTS: 
       cell1    - cell array of matrices representing a matrix by blocs.
                  blocs may be empty
       rowsizes - vector giving block height 
       colsizes - vector giving block width 

 OUTPUTS: 
       mat3 - double or symbolic array 
 
 ***** There are no parameters *****

 VERSION: '$Id: $'


 HISTORY:
 07-08-2008

 TO DO : 
 check ME in case of mixed symbolic and double 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 to deal with matrices whose size is not defined

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % fusions a block defined matrix stored inside cell array into one matrix
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: cell_fusion fusions a block defined matrix stored inside cell
0005 % array into one matrix
0006 %
0007 % CALL: [mat3] = ssm.cell_fusion(cell1, rowsizes, colsizes)
0008 %
0009 % INPUTS:
0010 %       cell1    - cell array of matrices representing a matrix by blocs.
0011 %                  blocs may be empty
0012 %       rowsizes - vector giving block height
0013 %       colsizes - vector giving block width
0014 %
0015 % OUTPUTS:
0016 %       mat3 - double or symbolic array
0017 %
0018 % ***** There are no parameters *****
0019 %
0020 % VERSION: '$Id: $'
0021 %
0022 %
0023 % HISTORY:
0024 % 07-08-2008
0025 %
0026 % TO DO :
0027 % check ME in case of mixed symbolic and double
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 function a_out = cell_fusion(a, rowsizes, colsizes)
0030 % to deal with matrices whose size is not defined
0031 rowsizes = max(zeros(size(rowsizes)), rowsizes);
0032 colsizes = max(zeros(size(colsizes)), colsizes);
0033 rowrank = cumsum([1 rowsizes]);
0034 colrank = cumsum([1 colsizes]);
0035 Nrow = length(rowsizes);
0036 Ncol = length(colsizes);
0037 a_out = zeros(rowrank(Nrow+1)-1, colrank(Ncol+1)-1);
0038 for i=1:Nrow
0039   for j=1:Ncol
0040     if ~isempty(a{i,j})
0041       rowmin = rowrank(i);
0042       rowmax = rowrank(i+1)-1;
0043       colmin = colrank(j);
0044       colmax = colrank(j+1)-1;
0045       if rowmax>=rowmin && colmax>=colmin 
0046         try
0047           a_out(rowmin:rowmax, colmin:colmax) = a{i,j};
0048         catch ME
0049           a_out = sym(a_out);
0050           a_out(rowmin:rowmax, colmin:colmax) = sym(a{i,j});
0051         end
0052       end
0053     end
0054   end
0055 end
0056 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003