Site hosted by Angelfire.com: Build your free website today!

insmat

PURPOSE ^

INSMAT Insert vector or matrix entries into matrix.

SYNOPSIS ^

function B=insmat(A,v,Ii,dim)

DESCRIPTION ^

INSMAT  Insert vector or matrix entries into matrix.
   INSMAT(X), returns X.
   INSMAT(X,V), tries to append matrix X with vector (or matrix) V.
   INSMAT(X,V,I), inserts row vectors V at rows I in matrix X.
      If I is an empty vector, X will be returned.
      In the indices I, only real parts are concidered and if they
      are not integers then they will be rounded off. Indices can be a
      logical array (see examples).
   INSMAT(X,V,I,DIM),  inserts vectors V along dimension DIM.
      If DIM < 1 or DIM > ndims(X), nothing will happen.

   The vectors in V are arranged row-wise.
   If V only have one row and there are multiple indices, then 
   V will be inserted repeatedly into those indices.
   Insertion is performed in a push-down fashion.
   The element(s) at an index of insertion are thus pushed downwards.

   Examples:
      X=rand(2,2,2)                  %X is 2x2x2.
      Y=insmat(X,[NaN Inf],2)        %inserts [NaN Inf] into row 2.
      Y=insmat(X,[NaN Inf -1 -2],2)  %inserts [NaN Inf -1 -2] into row 2.
      size(Y)                        %Y will be 3x2x2.
      Y=insmat(X,-[1 1;2 2],[1 3],2) %inserts vectors -[1 1] and -[2 2]
                                     %into column 1 and 2 respectively. Same as:
      Y=insmat(X,-[1 1 1 1;2 2 2 2],[1 3],2)
      size(Y)                        %Y will be 2x4x2.
         %Inputs NaNs in 3rd dim at indices 2 and 3:
      Y=insmat(X,repmat(NaN,1,4),[2 3],3)
      size(Y)                        %Y will be 2x2x4.
      X=1:3
      insmat(X,NaN,X==3,2)           %inserts NaN at the location where X==3.
      X=[1 1 2;1 2 3;2 3 3;3 3 3]
         %Inputs zero-vector at row locations containing both numbers 1 and 2:
      insmat(X,[0 0 0],any(X==2,2) & any(X==1,2),1)

   See also DELMAT, ROTMAT, SHIFTMAT, REPMAT, RESHAPE, FLIPDIM.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^


Generated on Sat 12-Mar-2005 01:01:49 by Rezaul Karim © 2004