When I overwrite an m-file in Matlab, the old version stays in memory. how can this be fixed?
Mostra commenti meno recenti
For various reasons, I have decided to write an m-file script using matlab code (using fprintf) and save this text file as a ".m" file. This works well, and I can later run this M-file. However, if I OVER-write an existing m-file, I have a problem.
Somehow, Matlab remembers what was in the previous version of this M-file. If I run this M-file (which I have over-written), the old version will run.
This can be a huge problem, because without knowing about this quirk someone would assume that Matlab would run the newly created m-file.
To get around this problem, I must open the new m-file in the editor, add a space, and then save the new m-file. This process will update the version of the script which is in the Matlab memory. This is a manual step which I would like to avoid, because it is easy to forget to do this step.
Is there any way to fix my problem? Is there any way to force Matlab to forget what was in the old version of my m-file (without manual manipulation)?
Risposte (1)
James Tursa
il 18 Mar 2016
Modificato: James Tursa
il 18 Mar 2016
After saving your new m-file, clear the old already-parsed m-file from memory. This will force MATLAB to read the new m-file the next time it runs the function/script.
clear your_mfile_name
Categorie
Scopri di più su Environment and Settings in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!