!(エスケープ演算子)内で変数を用いる
    4 views (last 30 days)
  
       Show older comments
    
    AKIHISA FUJII
 on 2 May 2023
  
    
    
    
    
    Commented: AKIHISA FUJII
 on 3 May 2023
            DNsample.exeというvisual studioでコンパイルした実行ファイルをmatlabスクリプト上で実行するため、!(エスケープ演算子)を使用しています。このファイルを実行すると、引数で指定したファイル名の画像が入手できるようになっています。
↓例

例で指定した引数の1つ目、strが得られる画像のファイル名を指しています。この例は実行可能でした。
今回、forループの中で本構文を使用し、画像のファイル名を変えていきたいのですが、エスケープ演算子内ではただの文字列として認識されるだけで、上で指定した変数を読み込んでくれているわけではなさそうです。(例の場合、ファイル名がstrとなる)

エスケープ演算子上でも変数を利用するにはどのような方法がありますでしょうか。
0 Comments
Accepted Answer
  Kojiro Saito
    
      
 on 3 May 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)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
