MATLAB Crashes When I Update and Copy in New Mex File

5 Ansichten (letzte 30 Tage)
Aaron Vose
Aaron Vose am 26 Mär. 2023
Kommentiert: James Tursa am 29 Mär. 2023
My mex files (e.g., "mymex.mexa64") work fine when I start MATLAB from scratch and run my code in a fresh environment.
However, when I've been working in MATLAB for a while, then modify my mex file and copy the new "mymex.mexa64" into my workspace, things then crash. I know the mex file is fine, because I can start MATLAB again, and everything works perfectly. It seems like MATLAB is not happy when I update the mex file when MATLAB has been running.
Is there a "reset mexfiles" or "clear mexfiles" or some other command that would make my mex files work when I copy new ones in after MATLAB has already been started? I'm assuming that MATLAB has some kind of cache for the mex files, and then when I copy in a new mex file, perhaps this breaks the cache?
Again, the problem is not my mex files. They are fine and always work when I start a fresh launch of MATLAB. The problem is when I copy mex files into the workspace after MATLAB has already been running.
Any ideas for how to get MATLAB to accept my mex files without having to close the entire MATLAB environment and start all over again?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Mär. 2023
clear mex
This will not affect files in use.
I am not sure what would happen if you had a function handle that refers to a mex file.
  4 Kommentare
Aaron Vose
Aaron Vose am 26 Mär. 2023
Thank you for your solution! This is now working for me:
clear mex
However, I need to be sure to stop all execution / debugging before running the command or it will crash.
James Tursa
James Tursa am 29 Mär. 2023
@Aaron Vose In spite of your protestations, this behavior is usually caused by bugs in your mex routine. Maybe you can shrink the code to a small example that reproduces this behavior and post it for us to inspect.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by