5.0

5.0 | 17 ratings Rate this file 140 Downloads (last 30 days) File Size: 2.28 KB File ID: #25387
image thumbnail

Write Cell Array to Text File

by Roland Pfister

 

22 Sep 2009 (Updated 12 Oct 2010)

A cell array is written to a delimited output file, incl. options for appending & custom delimiters.

| Watch this File

File Information
Description

This submission works similar as Sylvain Fiedlers / Rob Kohrs "cell2csv.m". Thus, any cell array containing numbers and/or strings can be written to an output file.

dlmcell.m, however, has two main advantages:

(1) It is possible to append the cell array to an existing file.

(2) Even numbers or words that are stored as <1,1> cell within the cell array can be read.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
cell2csv

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (18)
28 Oct 2009 Jeff Evans

works perfectly! just as described.

01 Nov 2009 Yonatan Cal

Thanks for this file!

01 Dec 2009 Russ Branaghan  
03 Dec 2009 Fabio Gori

It makes my life simpler!

27 May 2010 hugotang Tang

This function is good, thanks, man!

29 Aug 2010 Ivan Brezani

perfect, thanks!

08 Dec 2010 Rossella Blatt

Very useful! Works perfectly! Thanks.

21 Jan 2011 Boris  
12 May 2011 Matt Fetterman

Its OK. I had a problem...could be a Mac thing. Instead of making a new line in the file, the text appeared in the file as "Hello\n", that is the special characters appeared in the file.
To get around the problem I changed the program to read:
fprintf(fid,'%s\n',astring)
That is, I put the special character directly in the second parameter. Then it created a new line.

18 May 2011 Truc Phan

works great! thanks

28 Jun 2011 Seth  
05 Jul 2011 Michael

so awesome!

03 Aug 2011 Jane T

Like Matt I was having a problem with the '\t' appearing in the file. I'm running 2011a in Windows 7.
I changed line 100 to read 'fprintf(output_file,delimiter);'

13 Oct 2011 Ismael Seanez  
03 Nov 2011 Michael Krause

Great function, works awesome, was clearly missing as a built-in. Well done. (gave it 5 stars, but it's not showing up in Chrome??)

07 Dec 2011 Evan

This is an extremely useful script (thank you!) but I'm running into a little problem executing from Linux - slashes are appended between the fields before an after the delimiter - any ideas?

Example output text:
\Filename\,\StartDate\,\EndDate\,\Number of Measurements\

12 Dec 2011 daisy Dai

Great function! We've had problem with cell2csv, thanks to dlmcell that solves our trouble!

03 Jan 2012 none

excellent.

Please login to add a comment or rating.
Updates
12 Oct 2010

Little bugfix concerning %-signs.

Tag Activity for this File
Tag Applied By Date/Time
array Roland Pfister 23 Sep 2009 11:28:10
export Roland Pfister 23 Sep 2009 11:28:11
dlmwrite Roland Pfister 23 Sep 2009 11:28:11
data Roland Pfister 23 Sep 2009 11:28:11
data export Roland Pfister 23 Sep 2009 11:28:11
cell Roland Pfister 23 Sep 2009 11:28:11
tools Roland Pfister 23 Sep 2009 11:28:11
utilities Roland Pfister 23 Sep 2009 11:28:11
append Roland Pfister 23 Sep 2009 11:28:11
delimited Roland Pfister 23 Sep 2009 11:28:11

Contact us at files@mathworks.com