Why does "writecell" not write certain cell array data to an excel file?
Afficher commentaires plus anciens
Hello,
i have a 1x1 cell with char data (numerical values joined together with a delimiter, like '12.12;34.34;...'). In Matlab this data is somehow displayed as '''12.12;34.34;...''' after I save this data in another cell array. Where do the extra apostrophes come from? How can i prevent this from happening?
This is how the data is shown in the cell array inside Matlab. The triple apostrophes start at row 6 in the second column and this is exactly the data that is not written to the Excel file.

My guess is that due to the multiple apostrophes in the cell array the data is interpreted as an empty string and therefore everything after the first two apostrophes is ignored/not written but i don't know how to get rid of the unnecessary ones.
This is how i join the numerical values:
for m=1:size(timeseries,2)
timeseries{m} = num2str(timeseries{m}); % i haven't found a way to join numerical values together
end % without converting them to a string or char first
timeseries_demand = strjoin(timeseries,";");
I then save the data with:
result(end+1,[1,2]) = [id, timeseries_demand];
and write an excel (.xlsx) file with:
writecell(result(:,1), filename, "Sheet", "data", "Range", "A1");
writecell(result(:,2), filename, "Sheet", "data", "Range", "B1");
I'm using 2020b.
Thanks in advance.
3 commentaires
Kumar Pallav
le 28 Sep 2021
Is timeseries a variable you created, could you share the whole code and data so that I can reproduce the issue at my end.
Image Analyst
le 28 Sep 2021
What is the extension in filename? csv or xlsx or something else?
Patrik Schorn
le 29 Sep 2021
Modifié(e) : Patrik Schorn
le 29 Sep 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!