-1

I have a Simulink model from which I compiled an executable. Then, I'm using a batch file (*.bat) with 20 million lines of 'start /B model_name.exe' with a input file specified for each simulation as shown below:

start /B name_mdl.exe -u input_1.txt -o output_1.mat >>report_1.txt
start /B name_mdl.exe -u input_2.txt -o output_2.mat >>report_2.txt
start /B name_mdl.exe -u input_3.txt -o output_3.mat >>report_3.txt

and it goes on. "-u" and "-o" might be specific options to a customized tool with which the executable was built. I don't know if those are universal options. input_N.txt has a syntax: variable name = its value. report_N.txt has just bunch of information such as simulation run time, dates, times, etc.

Is there a way to have the batch file display (in Matlab command window) which cases are being run or how many have been performed? It would look like the below, maybe:

start /B name_mdl.exe -u input_1.txt -o output_1.mat >>report_1.txt
printf('%d case completed',num_case);
start /B name_mdl.exe -u input_2.txt -o output_2.mat >>report_2.txt
printf('%d case completed',num_case);

It could just be a main batch file that launches the batch file above, but also has lines of code to have the operating system periodically count *.mat files in the current directory and spit out the count in the command window.

Eric
  • 409
  • 2
  • 15

1 Answers1

0

You can use a for /l loop. The in clause defines(<start>,<increment>,<end>)

for /l %%i in (1,1,20000000) do (
  start /B name_mdl.exe -u input_%%i.txt -o output_%%i.mat >>report_%%i.txt
  echo started nr %%i 
)

(I can imagine, your PC gets over its limits with that. You should consider to limit the count of parallel processes)

To get the count of *.mat files, you can count them with:

for /f %%c in ('dir /b /a-d *.mat ^|find /c /v ""') do set count=%%c
echo There are %count% .mat files.
Stephan
  • 53,940
  • 10
  • 58
  • 91