% returns slice s orthogonal to dimension d from tensor t; % the result is a matrix function a = tgetmatrix(t,s,d) if (d < 1 | d > 3), error('d must be between 1 and 3') end tdim = tdimensions(t); tdim(d) = s; from = ones(3,1); to = tdim; from(d) = s; to(d) = s; a = tten2mat(tgetsubtensor(t,from(1):to(1),from(2):to(2),from(3):to(3)));