How to write a string matrix in to a txt file
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have stored some information in to a matrix sized n x 2. All cells are individual strings. The structure is like this:
A={[filename1.txt], []
[vector1 m x 1], [vector2 m x 1
[filename2.txt], []
[vector3 p x 1], [vector4 p x 1}
etc...
So the odd row is just a txt-file name and empty string and every second row has two information vectors (same sized). How to write this down to a file row-by-row.
Thank you.
2 Kommentare
Walter Roberson
am 23 Nov. 2017
Is your structure
A = {'filename1.txt', []; 'vector1 m x 1', 'vector2 m x 1'; ...}
or is it
A = {'filename1.txt', ''; 'vector1 m x 1', 'vector2 m x 1'; ...}
or is it
A = {"filename1.txt", ""; "vector1 m x 1", "vector2 m x 1"; ...}
or is it
A = {{'filename1.txt'}, {''}; {'vector1 m x 1'}, {'vector2 m x 1'}; ...}
or something else?
Antworten (1)
KSSV
am 23 Nov. 2017
fid = fopen('myfile.txt','w');
fprintf(fid,'%s\n',A{:});
fclose(fid);
3 Kommentare
Siehe auch
Kategorien
Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
