Ashhad Khan
Ashhad Khan

Reputation: 43

Executing a Powershell command from MATLAB

I'm trying to automate my workflow. So I'm generating a test list for my system in MATLAB. In the same script, I'm then waiting for a new log file which only gets generated when I run a python script in a certain directory through windows powershell. That python script would take the test list generated and produce a new log file. My code looks for the date of modification of that file, if it has changed, it means a new log file has been produced. The code then extracts certain strings of characters and then plot the result.

My question is how can I invoke powershell from MATLAB to invoke that python script execution command in a specific directory?

Regards

Upvotes: 2

Views: 2487

Answers (1)

Wolfie
Wolfie

Reputation: 30046

If you really want to commit to this Powershell-in-the-middle approach, you can call it with system

system( 'powershell -command "Some Powershell command"' );

You can collect outputs from this if there are any.


Seems like it would be easier to call the Python script from Matlab though and cut out the call to Powershell, this could also be done with the system command (i.e. without also calling Powershell in between). Or you could invoke Python directly.

Upvotes: 3

Related Questions