My MATLAB code has been replaced by a function of the file name. How to recover the code?
68 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1755634/image.png)
3 Comments
Image Analyst
on 19 Aug 2024 at 21:37
Edited: Image Analyst
on 19 Aug 2024 at 21:38
I don't even know what that means. What is "a function of the file name"? It looks like you have a function VsDistance in a file called VsDistance.m and in there are some comments, but they're followed by code that has nothing to do with the function description. Did you mistakenly paste over the code with your code and save it? If so try control-z a bunch of times (as long as you haven't exited MATLAB yet) to undo your changes.
Or see if there is a VsDistance.asv file in the same directory. That would be an automatically made backup file.
DGM
on 20 Aug 2024 at 17:37
Edited: DGM
on 20 Aug 2024 at 17:51
When you save a figure as 'mfig' instead of 'fig', saveas() creates both a .fig file and a .m file which will open the .fig file of the same name.
So it's possible a person could have a user-defined function or script VsDistance.m, create a figure, and then save the figure as VsDistance.fig, and unwittingly overwrite their working code -- or possibly just shadow it.
Answers (0)
See Also
Categories
Find more on Search Path 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!