how to write a array of string into a text file and how to read it back?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
dragoon
am 27 Okt. 2015
Beantwortet: Stalin Samuel
am 27 Okt. 2015
For example, I have a an array called `namelist` contains the following strings on each column:
'img1.png'
'img10.png'
'img100.png'
'img2.png'
...
I would like to record this array into a txt file and later read it back. (what I need is the order of those files).
What I am trying now is use
dlmwrite('namelist.txt',namelist)
But it gives me a really ugly txt file which contains
I,m,g,1,.,p,n,g,I,m,g,1,0,.,p,n,g,I,m,g,1,0,0,.,p,n,g,I,m,g,1,0,1,.,p,n,g,I,m,g,2,.,p,n,g,
and I have no idea how to read it back, i.e., to have array `nameless` as it before. I tried `dlmread` and `textscan` but none of them works... or I don't know the right way.
Any ideas?
0 Kommentare
Akzeptierte Antwort
Stalin Samuel
am 27 Okt. 2015
file_name = 'namelist.txt' ;
for i = 1:length(namelist)
current_line = namelist{i};
dlmwrite(file_name, current_line ,'delimiter','','-append', 'newline', 'pc');
end
data = importdata(file_name )
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!