iterate through text files and read them as a matrix
3 ビュー (過去 30 日間)
古いコメントを表示
Nitish Reddy Kotkur
2019 年 10 月 19 日
コメント済み: Turlough Hughes
2019 年 10 月 20 日
myfolderinfo=dir('dense_gnm_random_graph');%dense_gnm_random_graph is the folder which contains text files
N=length(myfolderinfo);
for i = 3:N
thisfile= myfolderinfo(i).name
A = readmatrix('thisfile','Whitespace',' []');
and these are the errors i got
Error using readmatrix (line 148)
Unable to find or open 'thisfile'. Check the path and filename or file permissions.
Error in final (line 6)
A = readmatrix('thisfile','Whitespace',' []');
0 件のコメント
採用された回答
Turlough Hughes
2019 年 10 月 20 日
編集済み: Turlough Hughes
2019 年 10 月 20 日
You have to make sure your filename and path are correct. Try modifying your input to readmatrix as follows:
A=readmatrix([myfolderinfo(i).folder '\' myfolderinfo(i).name],'Whitespace','[]')
3 件のコメント
Turlough Hughes
2019 年 10 月 20 日
Seeing as you've dedicated a question to the above I commented on that thread. Generally speaking I would opt to get the data in a nice format first rather than trying to solve afterwards. How are you generating the data? Or has it just been given to you?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!