Error using writecell: Nested cell arrays are not supported.

64 次查看(过去 30 天)
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

采纳的回答

Sivsankar
Sivsankar 2023-6-6
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by