My MATLAB code has been replaced by a function of the file name. How to recover the code?
68 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1755634/image.png)
3 个评论
Image Analyst
2024-8-19,21:37
编辑:Image Analyst
2024-8-19,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
2024-8-20,17:37
编辑:DGM
2024-8-20,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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!