Code covered by the BSD License  

Highlights from
CELLWRITE

4.90909

4.9 | 11 ratings Rate this file 24 Downloads (last 30 days) File Size: 1.46 KB File ID: #7363

CELLWRITE

by

 

05 Apr 2005 (Updated )

Cellwrite writes mixed cell array data to a CSV file.

| Watch this File

File Information
Description

This function implements the basic functionallity of csvwrite but operates on cell arrays of mixed data (numeric and string) instead of arrays of numeric data.

CELLWRITE(FILENAME, C) writes the cell array C to FILENAME as comma separated values.

Performance tests on 1000 by 100 matrices of random numeric data show performance nearly identical to CSVWRITE.

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
04 Jun 2012 Renwen Lin  
12 May 2012 Michael Neal

@Barry Williams:

I am just curious what made you give it four stars.

21 Aug 2011 Mohammad  
06 May 2011 Richard Moore

Works great! I changed the 'w' to an 'a' in the fopen statement so that I could add lines to the csv in successive calls in a loop.

13 Aug 2009 Guillaume Majeau-Bettez

Thanks so much, this is a lifesaver. Great when working on Linux OS. I added one line to replace any comma already existing in the texts by '_' before writing contents. Important if you have chemical names in there.
...
elseif isempty(contents)
contents = '';
else
contents=strrep(contents, ',' , '_' );
end

11 Jul 2009 Geoffrey Akien

I've been using this for a while now and its great but...one of the tests for changing numbers into text needs adjusting for logicals...

I change:
if isnumeric(contents)

into

if isnumeric(contents) || islogical(contents)

Because the logical class is not including in isnumeric (helpfully). It may add a small speed hit, but it increases the robustness a little.

Thanks for the program though!

10 Apr 2009 Kevin J. Delaney

Did just what I needed! Well done!

10 Sep 2008 David Hsieh  
10 Sep 2008 David Hsieh

This was terrific. I don't see why this WASN'T included with MATLAB originally, but it should definitely come standard.

11 Aug 2008 Ben Spivey

the {:} addition is needed when the cell array has one layer of embedded cell arrays - the format that textscan provides.

11 Aug 2008 Ben Spivey

I have noticed that Matlab 7.5 needs a revision to cellwrite to work with cells:

fprintf(fid,'%s\n',file_line) should be
fprintf(fid,'%s\n',file_line{:})

08 Feb 2007 Thomas Heinz

yes, why isn't it a standard function?! Thanks!

06 Feb 2007 Adam N

excellent! would be better if we could choose the delimiter i.e. tab, comma, semicolon, etc.
thanks!

31 Aug 2006 Kyle Archie

no idea why this is isn't already a standard function. Thanks!

28 Jul 2006 Barry Williams

Works well. Just what I needed!

Contact us