Home > analyzePRF > utilities > squish.m

squish

PURPOSE ^

function f = squish(m,num)

SYNOPSIS ^

function f = squish(m,num)

DESCRIPTION ^

 function f = squish(m,num)

 <m> is a matrix
 <num> is the positive number of initial dimensions to squish together

 return <m> squished.

 example:
 isequal(squish([1 2; 3 4],2),[1 3 2 4]')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f = squish(m,num)
0002 
0003 % function f = squish(m,num)
0004 %
0005 % <m> is a matrix
0006 % <num> is the positive number of initial dimensions to squish together
0007 %
0008 % return <m> squished.
0009 %
0010 % example:
0011 % isequal(squish([1 2; 3 4],2),[1 3 2 4]')
0012 
0013 % get the size of m
0014 msize = [size(m) ones(1,num-ndims(m))];  % add ones to end if necessary
0015 
0016 % calculate the new dimensions
0017 newdim = [prod(msize(1:num)) msize(num+1:end)];
0018 
0019 % do the reshape
0020 f = reshape(m,[newdim 1]);  % tack on a 1 to handle the special case of squishing everything together

Generated on Wed 18-Jun-2014 21:47:41 by m2html © 2005