3

I encountered a very strange problem when using the SYSTEM function to call an executable file from Matlab.

First, I can run the executable file in a window console with no problem. However, when I call system(foo.exe) in Matlab, it does nothing but return the status value -1.0737e+09, and it does not throw any warnings or errors.

I am using Matlab R2009b on a 32-bit windows system and the executable file depends on OpenCV2.40.

The system path variable definitely include all the required lib directories. I also tried adding the relevant paths in the LD_LIBRARY_PATH, and copying the dlls in the working directory. These attempts do not change anything.

I also tried calling SYSTEM('cmd') from Matlab, and running the executable in the invoked window console. It gave me no response, either. It seems like the running environment of the console called from Matlab is different from the original window console.

Running the same code on a different machine in Matlab is successful.

2
  • 1
    The code you're using for both the windows console and the function calls out of matlab would help us. Especially the last paragraph is not reproducible for me. Commented Sep 14, 2013 at 8:51
  • open a cmd window outside matlab and run the program - if this works check your working folder and ALL system environment variables by typing set command in the cmd window. Then try opening a cmd from within Matlab using system('cmd') try run the software again (as you said - this should fail). Check the running folder in the new cmd window and all system environment variables using set - compare them and see what is wrong. Commented Dec 27, 2013 at 7:26

1 Answer 1

4

I had this exact same problem. It turned out I simply needed to restart Matlab. I had not restarted Matlab after installing OpenCV2.1.

Sign up to request clarification or add additional context in comments.

1 Comment

I just wasted 1 hour before finding this thread and answer. This is indeed strange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.