!(エスケープ演算子)内で変数を用いる
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
AKIHISA FUJII
am 2 Mai 2023
Kommentiert: AKIHISA FUJII
am 3 Mai 2023
DNsample.exeというvisual studioでコンパイルした実行ファイルをmatlabスクリプト上で実行するため、!(エスケープ演算子)を使用しています。このファイルを実行すると、引数で指定したファイル名の画像が入手できるようになっています。
↓例
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1372839/image.png)
例で指定した引数の1つ目、strが得られる画像のファイル名を指しています。この例は実行可能でした。
今回、forループの中で本構文を使用し、画像のファイル名を変えていきたいのですが、エスケープ演算子内ではただの文字列として認識されるだけで、上で指定した変数を読み込んでくれているわけではなさそうです。(例の場合、ファイル名がstrとなる)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1372844/image.png)
エスケープ演算子上でも変数を利用するにはどのような方法がありますでしょうか。
0 Kommentare
Akzeptierte Antwort
Kojiro Saito
am 3 Mai 2023
evalコマンドの例
cmd = sprintf("!DNsample.exe %s 0 -2", str);
eval(cmd)
systemコマンドの例
cmd = sprintf("DNsample.exe %s 0 -2", str);
[status,cmdout] = system(cmd)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!