Clear Filters
Clear Filters

Error using writecell: Nested cell arrays are not supported.

92 views (last 30 days)
Hi all,
I have a cell and i want to export it as Excell, so i use "writecell" function. Unfortunately I am getting an error like below:
Error using writecell
Nested cell arrays are not supported.
How can i fix it?
Thank you for your answers.
Cem

Accepted Answer

Sivsankar
Sivsankar on 6 Jun 2023
The error message "Nested cell arrays are not supported" indicates the reason for the writecell error is due to the presence of nested cell arrays in the data you are trying to export.
You can fix this by converting the nested cell arrays into regular arrays or cells without any nesting. There are different ways to do this depending on the structure of your data. Here is a possible solution:
->Flatten the nested cell array: You can use the cell2mat function to convert the nested cell array into a regular array, as shown below:
data = {[1 2 3], [4 5 6; 7 8 9]};
flattenedData = cell2mat(data);
writecell(flattenedData, 'myfile.xlsx');
Note: Dont mind my use case data. I guess this shpuld not give that error anymore. Thanks!

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!