Matlab is busy after running system() command

Hi everybody,
I am running a cmd command via matlab using
system(cmd)
where cmd is my command and is starting a programm (Ansys Workbench).
However, after the program is loaded Matlab is still busy. Is there an alternative option to run a system command?
Running a batch file would also be ok. If I manually start the program with the batch file and then starting my Matlab script, everything works fine.
Thanks in advance and best regards
Felix

 Risposta accettata

Hi Felix,
In order for the MATLAB not to be busy, you have to close the program and then you can resume to work in MATLAB.
There's also an option that tells MATLAB not to wait for the program to be closed if you add the '&' symbol.
cmd = 'C:\...\_exe &';
system(cmd)
However, you should be (this is useful if you want to interact with simulation settings etc.) working with external API for ANSYS through the COM server. See actxserver function and documentation on API in ANSYS.

7 Commenti

Note that if you use the & at the end of the command, then system() will return as soon as it starts the Ansys process successfully, without waiting for Ansys to do any useful work.
In some cases you can meaningfully use & to do some pre-determined work, by creating a file of input for the command and redirecting input from the file. In other cases, though, there is a fair bit of difficulty getting the process to do specific things commanded by MATLAB.
Using the actxserver to command Ansys offers a lot more control.
I tried to use the actxserver, however I did not find a solution...
I am using the actxserver for Ansys Electronics, but I could not set it up with Ansys Workbench. Do you have any experience on that?
Thats why I am using the Ansys aaS matlab Toolbox.
However, the & helped me out and I can start Ansys workbench without getting stuck in busy mode.
Thank you both for your suggestions! helped me a lot!
Yes, but '&' won't get you anywhere if you are looking to get some results out of program. If you want to run it in batch mode as it looks like, here's a better way to do it, instead of system command.
I can't tell how to start ANSYS in automation mode, but you need ProgID for it, which you can get from documentation or you could Google how to find ProgID. Example with Excel, I tried to open ANSYS in the same way, but it doesn't work.
excelCOM = actxserver('Excel.Application')
Yes, thats the problem with Ansys Workbench.
What I am doing is the following:
  • starting Ansys workbench in interactive mode and write an ID.txt in the working directory:
'"C:\Program Files\ANSYS Inc\v202\Framework\bin\Win64\runwb2.exe" -I " with open("aaS_WbId.txt","w") as file:file.write(Server.StartServer("localhost",0,9000,9200))" '
  • with this ID I can setup an connection to Ansys now.
And you are totally right, if I do the & command, Ansys will not write these ID.txt in my working folder.
I tested the way with Process and I can start Ansys, but is there also an option to write the ID.txt?
Try supplying full path to file "aaS_WbId.txt"
Sergio Pena
Sergio Pena il 10 Ago 2022
Modificato: Sergio Pena il 10 Ago 2022
this is exactly what i've been looking for!
I've been looking to leave a background adb operation while other commands are being ran

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by