-1

For ex., I have Program 1 & Program 2, when I run commandPrograms program it will open up two buttons. One button will turn on and off Program 1, and the other button will turn on and off Program 2. I can turn on and off each program (Program 1 & Program 2) separately using the button brought up by the commandPrograms.

All programs in Matlab.

I have tried running it using batch parallelization, but quite unfamiliar and a beginner.

How can I run 2 separate programs simultaneously, each turned on and off by separate buttons?

Programs 1 & 2 do not interact. Unfortunately, I need to do it in Matlab.

Gad11ng
  • 27
  • 3
  • MATLAB is not a good platform for user multithreading. Some builtin functions make use of multithreading by themselve, but MATLAB does not give the user the possibility of starting multiple threads to run different scripts or functions. – Hoki Apr 04 '23 at 13:59

1 Answers1

1

You will need to share more details about interaction of those three programs.

If your Program 1 and Program 2 do not need to communicate (they are not dependant on each other or do not need their outputs), I would suggest that each button starts an instance of MATLAB that run each Program. This is a scribbly solution, if you share more details, I can update my answer.

!matlab.exe -r "cd c:\; try, disp('c:\outdir\my.m'); end; quit"

or

exeProgram = System.Diagnostics.Process;
exeProgram.StartInfo.Arguments = '-example arguments';
exeProgram.StartInfo.FileName = 'C:\program.exe'; % full file path
exeProgram.Start();
Mario Malic
  • 76
  • 1
  • 10