!(エスケープ演算子)内で変数を用いる
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
AKIHISA FUJII
le 2 Mai 2023
Commenté : AKIHISA FUJII
le 3 Mai 2023
DNsample.exeというvisual studioでコンパイルした実行ファイルをmatlabスクリプト上で実行するため、!(エスケープ演算子)を使用しています。このファイルを実行すると、引数で指定したファイル名の画像が入手できるようになっています。
↓例
例で指定した引数の1つ目、strが得られる画像のファイル名を指しています。この例は実行可能でした。
今回、forループの中で本構文を使用し、画像のファイル名を変えていきたいのですが、エスケープ演算子内ではただの文字列として認識されるだけで、上で指定した変数を読み込んでくれているわけではなさそうです。(例の場合、ファイル名がstrとなる)
エスケープ演算子上でも変数を利用するにはどのような方法がありますでしょうか。
0 commentaires
Réponse acceptée
Kojiro Saito
le 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)
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!