comparison m-toolbox/classes/@ssm/blockMatPrune.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 % blockMatPRUNE selects lines and columns of a block defined matrices stored in a cell array
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: cell_select selects lines and columns of a block defined
5 % matrices stored in a cell array
6 %
7 % CALL: [cell2] = ssm.cell_array_prune(cell1,rowindex,colindex)
8 %
9 % INPUTS:
10 % cell1 - block defined matrix in cell array
11 % rowsizes - vector giving block height
12 % colsizes - vector giving block width
13 %
14 % OUTPUTS:
15 % cell2 - cell array of matrices representing a matrix by blocs.
16 % blocs may be empty
17 %
18 % NOTE : function is private to the ssm class
19 %
20 % VERSION: '$Id: blockMatPrune.m,v 1.6 2011/04/08 08:56:22 hewitson Exp $'
21 %
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23
24 function varargout = blockMatPrune(varargin)
25
26 cell_in = varargin{1};
27 rowindex = varargin{2};
28 colindex = varargin{3};
29 Nrows = numel(rowindex);
30 Ncols = numel(colindex);
31
32 %% selecting content
33 cell_out = cell(Nrows, Ncols);
34 for ii=1:Nrows
35 for jj=1:Ncols
36 if ~isequal(cell_in{ii,jj}, []) || min(ii, Ncols)==min(jj, Nrows)
37 % if we have a non-empty cell or we are on the extended diagonal
38 cell_out{ii,jj} = cell_in{ii,jj}(rowindex{ii},colindex{jj});
39 end
40 end
41 end
42
43 varargout = {cell_out};
44 end