How can I input every file in a directory ending with .txt into my Matlab program while logged in through ssh?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a script/program that compares two inputs. I'd like the first input to stay the same throughout. For the other input, I want it to take in every single file ending with .txt in a directory, and execute the program.
How can I do so?
I'm working through ssh, so I'm not sure if that changes anything.
Also, would this code to run through all the files be placed in the command window or in my script?
0 件のコメント
採用された回答
per isakson
2015 年 11 月 14 日
編集済み: per isakson
2015 年 11 月 14 日
"every single file ending with .txt in a directory,"  
Try
sad = permute( dir( fullfile( folderspec, '*.txt' ) ), [2,1] );
for s = sad
fullfile( folderspec, s.name )
end
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2015 年 11 月 14 日
As your script takes two inputs, you should convert it to a function. Then create either a function (preferred) or script that calls upon it, using the techniques shown in
2 件のコメント
Thorsten
2015 年 11 月 14 日
That's fine. This is covered in the second part of the above reference:
"The second method is if you want to process all the files whose name matches a pattern in a directory. You can use the DIR function to return a list of all file names matching the pattern, for example all .txt files or all .csv files, or all files named myFilennnn.dat (where nnnn is some number)."
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!