elmat+ 2.2

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

2.4K Downloads

Updated Mon, 15 Dec 2003 09:28:47 +0000

No License

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.

Cite As

Rasmus Anthin (2023). elmat+ 2.2 (https://www.mathworks.com/matlabcentral/fileexchange/4007-elmat-2-2), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R10
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Added LINTIME to the package.