samer@4: function y=sli(x,i,dim) samer@4: % sli - Take a slice of a multidimensional array samer@4: % samer@4: % sli :: samer@4: % [Size:[[E]]->A] ~'E dimensional array of size Size, element type A', samer@4: % [[M]->1..Size(Dim)] ~'vector of M indices in Dim'th dimension', samer@4: % Dim:1..E ~'dimension to act along' samer@4: % -> [Size2:[[E]]->A] ~'new array of size Size2 :- samer@4: % Size2=set(Size,Dim,M) ~'new size same as old but with Dim'th entry replaced with M'. samer@4: samer@4: n=ndims(x); samer@4: idx=repmat({':'},1,n); samer@4: idx{dim}=i; samer@4: y=x(idx{:}); samer@4: