Mercurial > hg > ishara
view general/arrutils/sli.m @ 54:9bcf5e133bf0
Added from old stats library.
author | samer |
---|---|
date | Mon, 23 Feb 2015 16:08:09 +0000 |
parents | e44f49929e56 |
children |
line wrap: on
line source
function y=sli(x,i,dim) % sli - Take a slice of a multidimensional array % % sli :: % [Size:[[E]]->A] ~'E dimensional array of size Size, element type A', % [[M]->1..Size(Dim)] ~'vector of M indices in Dim'th dimension', % Dim:1..E ~'dimension to act along' % -> [Size2:[[E]]->A] ~'new array of size Size2 :- % Size2=set(Size,Dim,M) ~'new size same as old but with Dim'th entry replaced with M'. n=ndims(x); idx=repmat({':'},1,n); idx{dim}=i; y=x(idx{:});