How do I save a cell array as txt file?

I have a 1x34 cell array containing 34 file names and paths e.g., "C:\Users\Jack\Documents\MATLAB\Sample_Data\Raw\NSX100.NC5". I simply want a txt file containing this info, one path per line, in order to process them in batches at a later date.

回答(1 个)

One approach is just to use fprintf:
AC = {'abd', 'defg', 'hijklm', 'nop'};
fid = 1;
fprintf(fid, '%s\n', AC{:})
producing:
abd
defg
hijklm
nop

类别

在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by