From: Catalin Eberhardt on 6 May 2010 13:16 Hi there! I have a numerical matrix A, that I would like to write into a CSV or XLS file. I would like each column to have a header, so I defined the vector headerRow = ['H1' 'H2' 'H3' 'H4' 'H5' 'H6'] and then proceeded to write it into a CSV file, followed by the matrix A: csvwrite(fileName_XLS, headerRow) csvwrite(fileName_XLS, A) However this produces an empty first row! I also tried using "row,column" as extra parameters when calling csvwrite the second time, but that didn't work. I also tried adding the heading row to the matrix and then writing the matrix as a whole to the file, but this leads to problems since the matrix then contains both numbers and strings. I'd be very grateful if someone could recommend a way to write this matrix (+hear row) to a CSV/XLS file! Anticipated thanks.
From: Walter Roberson on 6 May 2010 14:12 Catalin Eberhardt wrote: > I have a numerical matrix A, that I would like to write into a CSV or > XLS file. I would like each column to have a header, so I defined the > vector > > headerRow = ['H1' 'H2' 'H3' 'H4' 'H5' 'H6'] > I'd be very grateful if someone could recommend a way to write this > matrix (+hear row) to a CSV/XLS file! Anticipated thanks. *If* you are on MS Windows and have Excel installed, and you are comfortable with Excel storing your file in binary rather than as text, then xlwrite() of the cell array should work. If you are on any other operating system, or you do not have Excel installed, or you need the file as text, then use fopen(), fprintf(), fclose() to write the data to a file yourself.
From: forkandwait w on 6 May 2010 14:36 > If you are on any other operating system, or you do not have Excel > installed, or you need the file as text, then use fopen(), fprintf(), > fclose() to write the data to a file yourself. .... and you should wrap it up in a function, so you can do > mycsvwrite(mat, header, file) whenever you want. I would poke around the file exchange for that too.
|
Pages: 1 Prev: What's the difference between SWT and the new NDWT ? Next: is image? |