Matlab and batch file
29 ビュー (過去 30 日間)
古いコメントを表示
Hi.
-i am not the most experienced matlab programer how ever, i am trying to exploite an batch script that i have previously writen.
by using uigetfile i will get an array of file names in Filnames i.e test.txt test2.txt test3.txt
i wish to pass this along to the batch script. and have tried !C:\test.bat Filnames(:,1) Filnames(:,2) Filnames(:,3)
but the batch script only recive the text as above: Echo Filnames(:,1) ......
any solultion to pass the found filname to an batch script ?
0 件のコメント
回答 (3 件)
per isakson
2013 年 5 月 11 日
I would do it this way
cmd = sprintf( 'c:\\test.bat %s %s %s', file(:,1), file(:,2), file(:,3) );
msg = dos( cmd );
because that allows me to inspect cmd. I can even copy&paste cmd to the Command Prompt and check that it works.
Replace dos by system if you are on Unix.
2 件のコメント
per isakson
2013 年 5 月 12 日
I just copied from the code you showed.
Either you handle the list of files in the bat-file or in Matlab, whichever is more convenient.
Image Analyst
2013 年 5 月 11 日
3 件のコメント
Image Analyst
2013 年 5 月 12 日
編集済み: Image Analyst
2013 年 5 月 12 日
Try this code, which I adapted from the FAQ by inserting your code before it:
startingFolder = fullfile(matlabroot, '\toolbox\images\imdemos');
[baseFileNames, chosenFolder] = uigetfile({'*.*','All Files,(*.*)'},'SELECT LOG FILE(S)',...
startingFolder,'Multiselect','on')
for k = 1:length(baseFileNames)
baseFileName = baseFileNames{k};
fullFileName = fullfile(chosenFolder, baseFileName);
message = sprintf('Now processing %s', fullFileName);
fprintf('\n%s\n', message);
promptMessage = sprintf('%s\n\nDo you want to Continue processing,\nor Cancel to abort processing?', message);
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
end
end
参考
カテゴリ
Help Center および File Exchange で Integrated Circuits についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!