Code covered by the BSD License  

Highlights from
slices

Be the first to rate this file! 17 Downloads (last 30 days) File Size: 2.44 KB File ID: #35439

slices

by

 

Slice a tensor (n-d matrix) along the d^th dimension.

| Watch this File

File Information
Description

%SLICES return a cell array of slices of a tensor along the specied dimension
%
% This function is useful for slicing high-dimensional images (e.g. fMRI
% images) into lower-dimensional pieces. The output can then be either
% processed directly, or passed into cellfun or arrayfun for further
% processing.
%
% USAGE:
% x = slices(m,[d])
%
% INPUTS:
%
% m: a tensor (i.e. multi-dimensional matrix) that you wish to slice
%
% d: the dimnsion along which you wish to make the slices. default:
% d = ndims(m).
%
% OUTPUTS:
%
% x: a 1 by size(m,d) cell array of slices of m. each element of the
% cell array is an (ndims(m) - 1)-dimensional tensor.
%
% EXAMPLE:
%
% %create a tensor to slice
% m = reshape(1:100,10,10);
%
% %slice along first dimension: returns rows of m
% s1 = slices(m,1);
%
% %slice along second dimension: returns columns of m
% s2 = slices(m,2);
%
% %slice along third (or greater) dimension: returns m as a cell array
% s3 = slices(m,3);
%
% SEE ALSO: REPMAT, CELLFUN, ARRAYFUN, JOIN
%
% AUTHOR: JEREMY R. MANNING
% CONTACT: manning3@princeton.edu

Acknowledgements

Join inspired this file.

This file inspired 2d And 3d Brain Plots.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
17 Sep 2013 Lennart

This is almost what I need. I see you implement the usage of a string as indexes. How did you manage to get MatLab to accept the colons? With my implementation it gives an error: http://stackoverflow.com/questions/18833203/how-to-slice-array-in-gui-function

Contact us