Why does "writecell" not write certain cell array data to an excel file?
10 views (last 30 days)
Show older comments
Patrik Schorn
on 24 Sep 2021
Answered: Patrik Schorn
on 30 Sep 2021
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Spreadsheets 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!