I am trying to write a 2 dimensional array variable with 6
rows and 4 columns into a csv file using csvwrite. my
first row is the column headers. I am not sure if csvwrite
can write headers? I tried removing the headers and it
worked fine but with the headers throws an error.
Raju Gain schrieb:
> Hello Everyone,
>
> I am trying to write a 2 dimensional array variable with 6
> rows and 4 columns into a csv file using csvwrite. my
> first row is the column headers. I am not sure if csvwrite
> can write headers? I tried removing the headers and it
> worked fine but with the headers throws an error.
>
> 'A' 'B' 'C' 'D'
> [ 1] [11] [12] [13]
> [ 2] [21] [22] [23]
> [ 3] [31] [32] [33]
> [ 4] [41] [42] [43]
> [ 5] [51] [52] [53]
>
> Can anyone tell me a way to write the values with the
> headers into a CSV file?
>
> Thanks
This should be a good starting point. I modified Francis Barnhart's
function CELLWRITE to do the same thing for me sometime ago. You may
change the permisions in fopen to 'a' (append). Then call the function
twice:
1st to write the header
2nd to write the array
You'll find it at MATLAB Central File exchange. I'm not sure if I'm
allowed to copy and paste hier!
Author: Francis Barnhart
Summary: Cellwrite writes mixed cell array data to a CSV file.
MATLAB Release: R13
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. http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=7363&objectType=file
RexGer
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.