Why does "writecell" not write certain cell array data to an excel file?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Patrik Schorn
el 24 de Sept. de 2021
Respondida: Patrik Schorn
el 30 de Sept. de 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 comentarios
Image Analyst
el 28 de Sept. de 2021
What is the extension in filename? csv or xlsx or something else?
Patrik Schorn
el 29 de Sept. de 2021
Editada: Patrik Schorn
el 29 de Sept. de 2021
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!