For engineers, grad students and researchers, MATLAB files often hold months of work: analysis scripts, functions, Simulink models and .mat files full of experimental or simulation data. When a script disappears after a crash, a .mat file will not load, or the drive holding your project folder suddenly stops responding, the right first steps can make the difference between a quick fix and lost work. Here is where to look and what to avoid.
Lost changes to a script after a crash
The MATLAB Editor can save automatic backup copies of files you are editing. By default these are stored in the same folder as the original file, with the same name and the extension .asv (for example, analysis.asv next to analysis.m). The settings are under Preferences > MATLAB > Editor/Debugger > Backup Files, where you can see whether backups are on, how often they are saved and whether they go to a different folder.
- Open the folder where the script lived and look for an
.asvfile with the same name. Make sure your file browser shows file extensions. - Copy it somewhere safe first, then rename the copy with a
.mextension and open it in MATLAB. - Compare it with the saved version before replacing anything, so you do not overwrite newer work.
Backup files are normally removed when you close a file normally, so look for them before reopening and closing the original repeatedly.
Scripts or folders that were deleted
- Check the Recycle Bin or Trash first, including on network shares, which may have their own recycle area.
- Check version control. If the project is in Git, earlier versions and deleted files can be restored from the repository history.
- Check MATLAB Drive if you use it. Sign in online and look through your files, including any deleted files area.
- Check other synced copies and backups: OneDrive, Dropbox, Google Drive, a university or company file share, Time Machine on a Mac, or File History on Windows. Cloud services usually keep previous versions and deleted files for a while.
If the files were deleted from a local drive and none of these have them, stop working on that drive. New files, temporary data and even MATLAB’s own preferences can overwrite the space where the deleted files still sit. This matters even more on SSDs, where deleted data can be cleared automatically by the drive.
A .mat file that will not load
An error when calling load on a .mat file usually means the file was not written completely, for example because MATLAB crashed, the disk filled up, a network connection dropped or a USB drive was removed mid-save. Some things to try:
- Work on a copy of the file, never the only original.
- Check the file size. A size of zero, or far smaller than expected, usually means the data was never written, and you will need an earlier copy.
- Try loading individual variables by name with
load(filename, 'varname'), or usematfileto read part of a large file. Sometimes only part of the file is damaged. - Look for earlier versions in your cloud service, backups or results folders. Many analysis pipelines can regenerate intermediate .mat files from raw data, which is another reason to keep raw data backed up separately.
When the drive is the real problem
If several files fail at once, or the computer itself is struggling, the storage may be failing. Warning signs include:
- MATLAB or File Explorer freezing when you open the project folder;
- clicking, beeping or grinding from a hard drive;
- an external drive that disconnects or asks to be formatted;
- a laptop that will not boot or reports a missing boot device;
- read errors or files that copy very slowly.
In that case, do not format the drive, do not run CHKDSK or Disk Utility First Aid on it, and do not install recovery software onto it. These tools write to the disk and can make a physical problem much worse. If the drive is still readable, copy your most important folders off first. If it is clicking, not detected or getting worse, switch it off.
How Data Retrieval can help
Our engineers evaluate the drive and give you a fixed quote, and recovery starts only when you approve it. We work from a copy of the drive, not the original, and recover your project folders, scripts, models and data files. We serve Los Angeles, the Inland Empire and Ventura County, and accept mail-in drives from anywhere in the US. See our hard drive data recovery, deleted file recovery and mail-in data recovery pages for details.
Get your research data back
If your MATLAB work was on a drive that has failed, or the files are gone and the steps above have not found them, call Data Retrieval at (323) 705-3997 or book a data recovery evaluation online.
