execute system commands in matlab

Hi
I can not figure out how to write the correct input for matlab system (or dos, I have tried both) commands.
That I want to do is to call the program HFSS with certain flags. I have verified that it works correctly in a CMD prompt. Here I use the line:
"C:\Program Files\HFSS11\HFSS11\hfss.exe" -runscriptandexit "D:\HFSS Projects\read_variable_from_file.vbs”
I can not make it work in matlab, I would appreciate if someone could help me.
My thanks in advance!
BR
Thomas

댓글 수: 9

What happens if you use
cmd = '"C:\Program Files\HFSS11\HFSS11\hfss.exe" -runscriptandexit "D:\HFSS Projects\read_variable_from_file.vbs"';
[status, msg] = system(cmd)
Thomas Schäfer
Thomas Schäfer 2021년 5월 6일
I get a -1 status return and HFF program does not start. I tried this before...
I am having difficulty finding a copy of the documentation for HFSS11 that is not on a crack site, as the software is from February 2009.
Try
2>&1
cmd = '"C:\Program Files\HFSS11\HFSS11\hfss.exe" -runscriptandexit "D:\HFSS Projects\read_variable_from_file.vbs" 2>&1';
[status, msg] = system(cmd)
and show the msg that results.
Thomas Schäfer
Thomas Schäfer 2021년 5월 6일
Hi
Thanks for puting time into this! I attached the HFSS help documentation for this.
I run the system comand with your input, msg is still empty (0×0 empty char array)
[status, msg] = system('"C:\Program Files\HFSS11\HFSS11\hfss.exe" -HELP')
and see if you get anything back. That is, we need to start by verifying that we are able to communicate with the program.
Also,
exename = "C:\Program Files\HFSS11\HFSS11\hfss.exe";
if exist(exename, 'file')
fprintf('okay, executable exists, "%s"\n', exename);
else
fprintf('executable does not seem to exist, "%s"\n', exename);
end
Thomas Schäfer
Thomas Schäfer 2021년 5월 6일
편집: Thomas Schäfer 2021년 5월 6일
[status, msg] = system('"C:\Program Files\HFSS11\HFSS11\hfss.exe" -HELP')
status = -1; msg = 0×0 empty char array
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
exename = "C:\Program Files\HFSS11\HFSS11\hfss.exe";
if exist(exename, 'file')
fprintf('okay, executable exists, "%s"\n', exename);
else
fprintf('executable does not seem to exist, "%s"\n', exename);
end
okay, executable exists, "C:\Program Files\HFSS11\HFSS11\hfss.exe"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As I said, then I run the comand in CMD pormt it works...
Also in matlab, just: system("C:\Program Files\HFSS11\HFSS11\hfss.exe") opens the HFSS.
Walter Roberson
Walter Roberson 2021년 5월 6일
I would tend to suspect DLL seach problems; https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order . For example that document hints that if there is a DLL loaded by MATLAB, then possibly hfss would attempt to use the already loaded DLL instead of doing any kind of searching for it. That could be a problem if the two DLLs have the same name but are different DLLs or different versions of the same basic DLL.
Thomas Schäfer
Thomas Schäfer 2021년 5월 6일
Okay.
I manage to solve this by running:
system('set path=%path:C:\Program Files\MATLAB\R2018b\bin\win64;=% & "C:\Program Files\HFSS11\HFSS11\hfss.exe" -runscriptandexit "D:\HFSS Projects\read_variable_from_file.vbs"');
I should ad that I am using MATLAB2019
Thanks again for you help!
Walter Roberson
Walter Roberson 2021년 5월 6일
Looks good.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2021년 5월 6일

댓글:

2021년 5월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by