How to run a MATLAB file in for loop in batch file step by step

4 ビュー (過去 30 日間)
Ali Sohrabi
Ali Sohrabi 2021 年 8 月 26 日
コメント済み: Ali Sohrabi 2021 年 8 月 29 日
Hope you are well. I am new to use batch files. I am trying to call MATLAB from the batch file several times. In this way, I used for loop to execute my MATLAB scripts several times. But what I got after running my batch file is to run all MATLAB files simultaneously. What I want is that, firstly, it runs once MATLAB, and when it is finished, it starts to run for the next time. Here is my code. Any help will be appreciated!
@echo off
for /l %%x in (1, 1, 2) do matlab -r "cd('H:\EngFiles\Ali\Backups codes\New set with multiple scenarios_Parallel');Bi_Objective_algorithm; exit"
pause

採用された回答

Raymond Norris
Raymond Norris 2021 年 8 月 27 日
Try using the -wait switch. E.g.
@echo off
for /l %%x in (1, 1, 2) do (
call matlab -wait -nosplash -r "cd('H:\EngFiles\Ali\Backups codes\New set with multiple scenarios_Parallel'); Bi_Objective_algorithm; exit"
)
  1 件のコメント
Ali Sohrabi
Ali Sohrabi 2021 年 8 月 29 日
Thanks for your suggestion, now it works well!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by