Concatenation of nested cell in one array and writing in text file
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nazar Adamchuk
el 26 de Abr. de 2021
How do I rearrange a 8x1 nested cell into one long cell array (variable attached). Each (from 8) cell includes 2x1 cell. My goal is twofold:
- saving the of the 8x1 nested cell in a cell array
- writing the unnested cell array to a text file

Thanks!
0 comentarios
Respuesta aceptada
Jan
el 26 de Abr. de 2021
Data = load('nestedCell.mat');
C = cat(2, Data.nestedCell{:});
FID = fopen('YourFile.txt', 'w');
fprintf(FID, '%-8s%g\n', C{:});
fclose(FID)
2 comentarios
Jan
el 26 de Abr. de 2021
Editada: Jan
el 26 de Abr. de 2021
Try it:
fprintf('*%-8s*\n', 'asd')
fprintf('*%8s*\n', 'asd')
The 8 is the number of chars reserved for the output. With - the string is moved to the left, without - to the right. So this is only to have a nice formatted output. See:
doc fprintf
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays 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!