table to excel code update

in matlab 2020 my code was working very good when i update to 2021 my code didn't work any more and it says Error using cellfun
Input #2 expected to be a cell array, was struct instead.
my code was i don't know what is change in matlab 2021a ? and how to correct it
to convert table with struct to excel sheet
if true
n = cellfun(@length,result.bw);
f = repelem(result.fileName,n);
s = vertcat(result.bw{:});
s = struct2table(s);
s.fileName = f;
writetable(s,'myexcel.xlsx');
end

3 comentarios

Image Analyst
Image Analyst el 18 de Jul. de 2021
Not sure what bw is, but if it's an image length(bw) will give you the largest of either (1) the number of columns in the image, or (2) the number of rows in the image. I really don't know what you're after because there are no comments to give example expected results. If you want to write f, just write f. Why are you adding it to a structure and then trying to write the structure???
So edit your original post and
  1. add comments to your code and
  2. add result in a .mat file with the paperclip icon
save('answers.mat', 'results');
Then I can work on fixing it.
Walter Roberson
Walter Roberson el 18 de Jul. de 2021
https://www.mathworks.com/matlabcentral/answers/795837-how-to-convert-table-with-struct-to-excel-sheet?s_tid=srchtitle appears to be relevant.
So whatever was storing cell array of struct array into the table object is storing something else instead. We would need the code that is creating the bw variable in the table object.
hussain abdelaziz
hussain abdelaziz el 23 de Jul. de 2021
this is in attachment the code which get the table ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 18 de Jul. de 2021

Comentada:

el 23 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by