MATLAB Answers

0

How can I export a 2D cell into either a .csv or .xls file?

Asked by M Jaskir on 12 Jun 2019
Latest activity Answered by Star Strider
on 12 Jun 2019
Hi all! A script I'm writing is taking a group .csv files, running a filter through them in MATLAB, and (ideally) exporting this data back into a different excel file. This "filtered" version of the data comes out of a function I've written as a 200000 (or so depending on the file) x 17 cell. However, I'm struggling to accomplish this, even after trying xlswrite (got an error that it could not read a cell input). If all I care about is essentially exporting this cell exactly as it appears in MATLAB (with 17 columns), is there a concise way of achieving this? I was troubleshooting using cellplot(data(:,:)) to ensure the data has been filtered correctly, but beyond that, I'm having difficulty. Thank you!

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Star Strider
on 12 Jun 2019

I’m not certain what your cell contains.
One option is to use the cell2mat (link) functiion to convert it to a matrix, then use writematrix (link) (or xlswrite (link)). Both of them appear to want matrices, not cell arrays, so the conversion to a matrix is necessary to use them.
Another option that might be more appropriate is to use the cell2table (link) function and then the writetable (link) function.

  0 Comments

Sign in to comment.