Code covered by the BSD License  

Highlights from
cell2file

4.66667

4.7 | 3 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.56 KB File ID: #17954

cell2file

by Luca Cerone

 

11 Dec 2007 (Updated 06 May 2008)

cell2files writes cells of a cellarray (both numeric and text ones) to a file

| Watch this File

File Information
Description

cell2file writes a cell array of strings, or number into a file
==This function has been obtained modifyng the file str2file.m I found in the FEX.==
Last Modified: 2008/01/09 (yyyy/mm/dd).
 
 Syntax: cell2file(fid,cell,....) where ... is in the format PARAMETER, VALUE

 Possible Parameter are: 'EndOfLine'
to choose how to end lines (ex:\r\n),
default: \n)

'Delimiter' to choose the delimiter beetween two value of the same row,
default: ';'
 
 cell2str can write to a file both sting and numeric format.
 
 You just have to pass the handle to the file
(so that you can choice your opening attribute) and the cellarray.
 
 Ex:
 A={'prova',[1],'prova';
 [3],'txt',[4]};
 
 fid=fopen('prova.log','a+');
 cell2file(fid,A,'EndOfLine','\r\n');
 fclose(fid);

Acknowledgements

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

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
05 Jan 2008 CH Ooi

thanks so much. this is a nifty function ^__^b

25 Jul 2008 John Liu

awesome! this is very helpful. thanks

11 Sep 2008 Hema Tanikella

Thanks! this is helpful. I am a beginner to MATLAB and this helps me output text the way I want to output it. However, I have a question. If I use this file in a for-loop with each loop writing a single row, the program does not start the next loop on a new line. I am wondering how to modify this to do that. Thanks

Please login to add a comment or rating.
Updates
11 Jan 2008

Added two new options.

06 May 2008

now the line does end only with EndOfLine Character

06 May 2008

Bug fix:
now it doesn't write delimiter after last element and doesnt write an EndOfLine
after last Row.

Tag Activity for this File
Tag Applied By Date/Time
data import Luca Cerone 22 Oct 2008 09:38:42
data export Luca Cerone 22 Oct 2008 09:38:42
cell Luca Cerone 22 Oct 2008 09:38:42
file writing Luca Cerone 22 Oct 2008 09:38:42
cellarray Luca Cerone 22 Oct 2008 09:38:42
export Luca Cerone 22 Oct 2008 09:38:42
export cell Luca Cerone 22 Oct 2008 09:38:42
export cellarray Luca Cerone 22 Oct 2008 09:38:42

Contact us at files@mathworks.com