diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@ssm/blockMatPrune.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,44 @@
+% blockMatPRUNE selects lines and columns of a block defined matrices stored in a cell array
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: cell_select selects lines and columns of a block defined
+%              matrices stored in a cell array
+%
+% CALL: [cell2] = ssm.cell_array_prune(cell1,rowindex,colindex)
+%
+% INPUTS:
+%       cell1    - block defined matrix in cell array
+%       rowsizes - vector giving block height
+%       colsizes - vector giving block width
+%
+% OUTPUTS:
+%       cell2 - cell array of matrices representing a matrix by blocs.
+%               blocs may be empty
+%
+% NOTE : function is private to the ssm class
+%
+% VERSION: '$Id: blockMatPrune.m,v 1.6 2011/04/08 08:56:22 hewitson Exp $'
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout  = blockMatPrune(varargin)
+  
+  cell_in = varargin{1};
+  rowindex = varargin{2};
+  colindex = varargin{3};
+  Nrows = numel(rowindex);
+  Ncols = numel(colindex);
+  
+  %% selecting content
+  cell_out = cell(Nrows, Ncols);
+  for ii=1:Nrows
+    for jj=1:Ncols
+      if ~isequal(cell_in{ii,jj}, []) ||  min(ii, Ncols)==min(jj, Nrows)
+        % if we have a non-empty cell or we are on the extended diagonal
+        cell_out{ii,jj} = cell_in{ii,jj}(rowindex{ii},colindex{jj});
+      end
+    end
+  end
+  
+  varargout = {cell_out};
+end