How can I restore or recover a MATLAB file that I accidentally deleted or lost?

조회 수: 284 (최근 30일)
How can I restore or recover a MATLAB script or function (M file) that was accidentally deleted, overwritten, or lost?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2025년 2월 24일
편집: MathWorks Support Team 2025년 2월 24일
In the event of lost or accidentally deleted or overwritten MATLAB files, there are a few places to look for backup files and previous versions of the file, although it is not guaranteed they will exist:

1. Autosave Files

By default, MATLAB is configured to automatically save a backup copy of any modified file every five minutes using an ASV extension. For instance, if your file is named filename.m, the backup will be filename.asv. You can recover the unsaved changes by opening the backup copy of the file, "filename.asv," and saving it as "filename.m". Refer to the Save and Back Up Code Documentation for more context and further instructions
These backup files should be in the same directory as the original file. If not, go to MATLAB Home > Preferences > Editor/Debugger > Backup Files and check to see if you have specified a directory in which to store the backup files (under "Location" and  "Single directory"). However, note that backup files would have been deleted upon closing the editor if the option "Automatically delete backup files when the Editor closes" is checked. Moving forward, consider unchecking this option to retain backups.

2. Operating System Backup Features

If a backup system is in place, such as Microsoft File History or Mac Time Machine, it may be possible to restore previous versions of your files if your operating system has saved them. Consult the following resources:
For Windows, if File History is enabled, open File Explorer, right-click on the .m file, and select "Restore previous versions," at which point a previous version may be recoverable. 

3. Cloud Storage Services

If you utilize programs that automatically synchronize files between your local hard drive and cloud storage service MATLAB Drive Connector, Microsoft OneDrive, Google Drive, iCloud, or Dropbox, files can possibly be restored through these services. 

4. Third-Party Recovery Tools

If your operating system has not saved any past versions of the file, then unfortunately it is very difficult, if not impossible to recover the lost file. As a last resort, you can try Third-Party Recovery Tools or Professional Data Recovery Services.

5. Further Reading

You can find more ideas for recovering MATLAB files and other data on the page below:Recovering Data After Abnormal Termination - MATLAB Documentation

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by