passing filenames to a dos command
古いコメントを表示
I would like to use an DOS executable command. The command requires file input and output names.
I cannot figure out how to pass the filenames (which are characters in the Matlab program).
For example the executable I want to run is "dcmdjpeg", so I have tried using
dos('.\dcmdjpeg FileIn FileOut'), but offcourse once I have the apostrophes DOS does not know what FileIn and FIleOut are.
Ive also tried
eval('!.\dcmdjpeg' FilNamIn FilNamOut);
Again this doesnt work.
回答 (2 件)
Kunal Kandhari
2023 年 8 月 17 日
To pass the filenames to the dos command, you need to properly construct the command string to include the file names.
Here's how you can do it:
% Replace these with your actual file names
FileIn = 'input_file_name';
FileOut = 'output_file_name';
command = sprintf('.\\dcmdjpeg %s %s', FileIn, FileOut);
output = dos(command);
Where "sprintf" is a string formatter, you can read more about it here: sprintf
Hope it helps!
Star Strider
2023 年 8 月 17 日
0 投票
カテゴリ
ヘルプ センター および File Exchange で MATLAB Mobile についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!