フィルターのクリア

how to write a array of string into a text file and how to read it back?

4 ビュー (過去 30 日間)
dragoon
dragoon 2015 年 10 月 27 日
回答済み: Stalin Samuel 2015 年 10 月 27 日
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?

採用された回答

Stalin Samuel
Stalin Samuel 2015 年 10 月 27 日
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 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by