Matlab shuts down after executing a mex call
Show older comments
Hi,
I'm calling a C++ function using Mex. The function call works fine. After the file is called and the result is displayed, Matlab shuts down by itself. How do I stop this from happening?
Accepted Answer
More Answers (2)
Walter Roberson
on 4 Mar 2012
0 votes
You probably have some memory corruption in the C++ function, with the effect of the corruption being observed when MATLAB goes to clear the variables that are no longer being used.
4 Comments
Vimal
on 5 Mar 2012
Walter Roberson
on 5 Mar 2012
Try posting code. James is pretty good at spotting mex problems if he has code to work with.
Vimal
on 5 Mar 2012
Vimal
on 5 Mar 2012
Walter Roberson
on 5 Mar 2012
0 votes
What do you do with the value you return from test() at the C level ? You are not somehow putting it in the the output location x (plhs[0]) in your mexFunction routine .
2 Comments
Vimal
on 5 Mar 2012
Walter Roberson
on 5 Mar 2012
True that test() at your C level could return void, but at the MATLAB level you have indicated that you are expecting a return value from the call to the MEX routine, and you never set the return value to anything.
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!