Code covered by the BSD License  

Highlights from
Cell2Vec

5.0
5.0 | 1 rating Rate this file 18 Downloads (last 30 days) File Size: 10.1 KB File ID: #28916 Version: 1.1
image thumbnail

Cell2Vec

by

Jan Simon (view profile)

 

01 Oct 2010 (Updated )

Concatenate cell elements to a vector - fast C-Mex

| Watch this File

File Information
Description

CELL2VEC - Concatenate cell elements to a vector
V = Cell2Vec(C)
INPUT:
  C: Cell array of any size and types:
        DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR.
      The elements of C can have different sizes.
OUTPUT:
  V: [1 x N] vector of all elements.

EXAMPLE:
  C = {1, 2; 3, 4};
  V = Cell2Vec(C) % [1, 3, 2, 4] columnwise order
  M = reshape(V, size(C)) % [1, 2; 3, 4]

This C-Mex is up to 5 times faster than CAT(C{:}), HORZCAT or CELL2MAT.

Pre-compiled Mex-files can be downloaded: http://www.n-simon.de/mex
Run the unit-test uTest_Cell2Vec after compiling.

Tested: Matlab 6.5, 7.7, 7.8, WinXP, 32bit
        Compiler: LCC2.4/3.8, BCC5.5, OWC1.8, MSVC2008
Assumed Compatibility: higher Matlab versions, Mac, Linux, 64bit

See also: CStr2String, CELL2MAT.

MATLAB release MATLAB 7.13 (R2011b)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
12 Feb 2012 Jan Simon

Jan Simon (view profile)

@Misha, you have to compile the C-file as described in the section "COMPILATION" in the help text - see "help Cell2Vec".

Comment only
12 Feb 2012 Misha

Misha (view profile)

Hi Jan,
Am I doing something wrong in trying to use this patch? I've dropped it in my main matlab folder. When I try to run:

a =

1 5 9
2 6 10
3 7 11
4 8 12

>> v = cell2vec(a)

i get an error:
Error using Cell2Vec (line 41)
Cannot find Mex file of Cell2Vec

Comment only
01 Oct 2010 Quant Guy

Quant Guy (view profile)

This is very useful tool and important submission. I was able trivially to reimplement the out of the box implementation of cell2mat which is very slow and got huge increases in overall speed!!

Updates
03 May 2015 1.1

Better error messages and cleaned help section.

Contact us