unix command in for loop
4 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to execute a shell command using the unix command within a for loop. The first part of the code deals with dumping a list of files into a .txt file named firstfile.txt. The part that is giving me trouble is specifically in the unix command portion of the code. The code is below.
filename=importdata('firstfiles.txt'); %importing list of files as an array
filename1=char(filename); %converting to character
for 1:length(filename);
filename2=filename1(i);
command1='simpleTranslate -z --outstyle=2 -q0 -n5000 filename2 > test.txt';
[x,y]=unix(command1);
more code that isn't relevant to this problem % code
end
The simpleTranslate portion of the command1 is a custom linux code that I'm calling on, but the primary problem is the filename2 variable. I don't know how to get the unix command to step through each file name within the filename2 array. Any insights into this problem would be very appreciated. Thanks!
0 件のコメント
回答 (2 件)
Ken Atwell
2013 年 10 月 27 日
Your command line being sent to unix() includes the string 'filename2', not the value of filename2. Try:
command1= ['simpleTranslate -z --outstyle=2 -q0 -n5000 ' filename2 ' > test.txt'];
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!