Trouble Opening Program using System()

12 Ansichten (letzte 30 Tage)
Luke Driver
Luke Driver am 11 Jul. 2023
Kommentiert: Luke Driver am 12 Jul. 2023
Hi,
So im trying to open a program (Ansys ICEM) through MATLAB. The code I have setup to run the file is:
ICEM_Path = 'C:\Program Files\ANSYS Inc\v221\icemcfd\win64_amd\bin\icemcfd';
ICEM_Script = [currentFolder, '\ICEM_Script.tcl'];
system(['"' ICEM_Path '" -script "' ICEM_Script '"']);
Now MATLAB opens up the program fine, but it doesnt work with any of my scripts that I want it to. This is weird because when i open up the program through the taskbar, or just open it in its file location outside of MATLAB everything works fine as expected. Is there some problem with the environment variables?
When I open the program normally a terminal opens with the program (I would assume to let the program call function and perform them). But When I open it through MATLAB it doesnt open this terminal, and I would suspect that this is why its not working as usual. Does anyone know what the problem may be?

Antworten (1)

the cyclist
the cyclist am 11 Jul. 2023
Looking at the string you are providing to the system command, I think you want
system(['"' ICEM_Path ' -script ' ICEM_Script '"']); % Removed the double quotes around -script
rather than
system(['"' ICEM_Path '" -script "' ICEM_Script '"']);
I'm not sure you need the outermost double-quotes either, so I think
system([ICEM_Path ' -script ' ICEM_Script])
will work.
  1 Kommentar
Luke Driver
Luke Driver am 12 Jul. 2023
The code was already working, I was just wondering if there was an environment issue. This is because I can open up my program using the taskbar (and it works completely fine), but when I open it with MATLAB some of the commands in the program do not work. So I'm thinking MATLAB is doing something (maybe the environment) to change its behavior.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by