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

2 views (last 30 days)
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!

Answers (1)

Star Strider
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.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!