elmat+ 2.2

版本 1.0.0.0 (5.7 KB) 作者: Rasmus Anthin
Deleting indices, inserting vectors and rotating/shifting matrix. Multidimensional.
2.4K 次下载
更新时间 2003/12/15

无许可证

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.

引用格式

Rasmus Anthin (2024). elmat+ 2.2 (https://www.mathworks.com/matlabcentral/fileexchange/4007-elmat-2-2), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R10
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Added LINTIME to the package.