Mercurial > hg > ltpda
comparison m-toolbox/classes/@ssm/blockMatFusion.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % fusions a block defined matrix stored inside cell array into one matrix | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: blockMatFusion fusions a block defined matrix stored inside cell | |
5 % array into one matrix | |
6 % | |
7 % CALL: [mat3] = ssm.blockMatFusion(cell1, rowsizes, colsizes) | |
8 % | |
9 % INPUTS: | |
10 % cell1 - cell array of matrices representing a matrix by blocs. | |
11 % blocs may be empty | |
12 % rowsizes - vector giving block height | |
13 % colsizes - vector giving block width | |
14 % | |
15 % OUTPUTS: | |
16 % mat3 - double or symbolic array | |
17 % | |
18 % NOTE : function is private to the ssm class | |
19 % | |
20 % VERSION: '$Id: blockMatFusion.m,v 1.3 2010/08/27 13:02:45 adrien Exp $' | |
21 % | |
22 % TO DO : | |
23 % check ME in case of mixed symbolic and double | |
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
25 | |
26 function a_out = blockMatFusion(a, rowsizes, colsizes) | |
27 % to deal with matrices whose size is not defined | |
28 rowrank = cumsum([1 rowsizes]); | |
29 colrank = cumsum([1 colsizes]); | |
30 Nrow = length(rowsizes); | |
31 Ncol = length(colsizes); | |
32 isEmpty = cellfun(@isempty, a); | |
33 | |
34 a_out = zeros(rowrank(Nrow+1)-1, colrank(Ncol+1)-1); | |
35 for ii=1:Nrow | |
36 for jj=1:Ncol | |
37 if ~isEmpty(ii,jj) | |
38 rowmin = rowrank(ii); | |
39 rowmax = rowrank(ii+1)-1; | |
40 colmin = colrank(jj); | |
41 colmax = colrank(jj+1)-1; | |
42 try | |
43 a_out(rowmin:rowmax, colmin:colmax) = a{ii,jj}; | |
44 catch ME | |
45 a_out = sym(a_out); | |
46 a_out(rowmin:rowmax, colmin:colmax) = sym(a{ii,jj}); | |
47 end | |
48 end | |
49 end | |
50 end | |
51 end |