No BSD License  

Highlights from
elmat+ 2.2

5.0

5.0 | 1 rating Rate this file 10 Downloads (last 30 days) File Size: 5.67 KB File ID: #4007

elmat+ 2.2

by

 

25 Sep 2003 (Updated )

Deleting indices, inserting vectors and rotating/shifting matrix. Multidimensional.

| Watch this File

File Information
Description

This extension package for the intrinsic elmat (elementary matrices and matrix manipulation) matlab toolbox contains five routines yet so far: LINTIME, DELMAT, INSMAT, ROTMAT and SHIFTMAT.
Names are consistent with LINSPACE and REPMAT but not with SHIFTDIM, since I want them to have similar names (easier to remember).

%%%%%%

LINTIME creates a linearly spaced vector with N elements starting from T0 and being spaced by DT.
This function is very similar to linspace and the colon operator ":" but they are based on different assumptions. For each method the following is known:

COLON OPERATOR : start, step, end
LINSPACE : start, end, amount
LINTIME : start, step, amount

by "amount" we mean the number of elements.

%%%%%%

DELMAT removes vector entries from a matrix, INSMAT inserts vector entries into a matrix at given indices, ROTMAT rotates elements and SHIFTMAT shift elements and "pads" the trailing elements with zeros (or a predifined value). The input matrix can be multidimensional and all routines operate along any dimension.

Syntaxes:
%%%%%%%
DELMAT(X,I,DIM)
X : multidimensional matrix
I : indices to remove
DIM : dimension to work along
%%%%%%
INSMAT(X,V,I,DIM)
X : multidimensional matrix
V : vector(s)/matrix(es) to insert
I : indices where vector(s)/matrix(es) are to be inserted
DIM : dimension to work along
%%%%%%
ROTMAT(X,N,DIM)
X : multidimensional matrix
N : number of steps
DIM : dimension to work along
%%%%%%
SHIFTMAT(X,N,DIM,PAD)
X : multidimensional matrix
N : number of steps
DIM : dimension to work along
PAD : values to pad the matrix with after shifting.
%%%%%%
default values (if omitted) for all routines:
I = []
DIM = 1
V = []
N = 0
PAD = 0
%%%%%%

Some examples:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Removes column 2 and 3:
delmat(X,2:3,2)

%X is a vector. Removes elements with values between 1 and 5:
delmat(X,1<X & X<5,2)

%Rotates matrix one step along 3rd dim:
rotmat(X,1,3)

%Shifts matrix one step down (pads with zeros):
shiftmat(X,1)

%shifts two steps left with trailing NaNs.
shiftmat(X,-2,2,NaN)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(NB! the indentations of the help-sections shown above might be corrupted on this page.)

There might be something similar to the routines DELMAT and INSMAT that already exist. But it is nothing I've been avare of yet so far. There exist clones for SHIFTMAT and ROTMAT, however I wanted to keep these routines having consistent syntax. That's why I decided to do my own versions.

Works for MATLAB 5.1 and upwards.

Acknowledgements

This file inspired Random Deletion Of Matrix Vectors and Soft Thresholding For Image Segmentation.

MATLAB release MATLAB 5.2 (R10)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
13 Apr 2006 fabio echegaray

it is just what i needed

Updates
30 Sep 2003

Changed the package name from elfun+ to elmat+, since it contains elementary functions dealing with matrices.
Also changed names of the functions to DELMAT and INSMAT to be consistent with REPMAT etc...

28 Oct 2003

Added two more functions: ROTMAT and SHIFTMAT (names are pretty self explanatory).
Also made it possible to use logical arrays as indices for DELMAT and INSMAT.

30 Oct 2003

Bugfixes. SHIFTMAT didn't work properly (now it works fine). Indicies had to be row vectors, but now they don't have to.

Contact us