Mercurial > hg > ishara
annotate general/arrutils/sli.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | e44f49929e56 |
children |
rev | line source |
---|---|
samer@4 | 1 function y=sli(x,i,dim) |
samer@4 | 2 % sli - Take a slice of a multidimensional array |
samer@4 | 3 % |
samer@4 | 4 % sli :: |
samer@4 | 5 % [Size:[[E]]->A] ~'E dimensional array of size Size, element type A', |
samer@4 | 6 % [[M]->1..Size(Dim)] ~'vector of M indices in Dim'th dimension', |
samer@4 | 7 % Dim:1..E ~'dimension to act along' |
samer@4 | 8 % -> [Size2:[[E]]->A] ~'new array of size Size2 :- |
samer@4 | 9 % Size2=set(Size,Dim,M) ~'new size same as old but with Dim'th entry replaced with M'. |
samer@4 | 10 |
samer@4 | 11 n=ndims(x); |
samer@4 | 12 idx=repmat({':'},1,n); |
samer@4 | 13 idx{dim}=i; |
samer@4 | 14 y=x(idx{:}); |
samer@4 | 15 |