MATLAB unable to find files
Show older comments
I am working on a project and MATLAB fails to open files for me. I downloaded some .m files off of my OneDrive and they were perfectly fine and uncorrupted. Furthermore, I was able to view them in OneDrive without issue. When I downloaded the file and put it into the folder where I was working in, the file didn't open when I tried to double click it.
MATLAB told me it was unable to find the file despite the fact that it was in the folder I was working in and returned the correct path. When attempting to troubleshoot, I noticed that one recommendation was to have MATLAB use the default folder in Documents/MATLAB. Since that folder was in my OneDrive for some reason, I made a new one saved on my computer and tried to have MATLAB open to that upon start-up. MATLAB then told me the folder didn't exist when I tried to submit the new path.
Ultimately, I decided to copy the contents of the .m file and paste it into a new .m file created through MATLAB, which worked just fine. However, I cannot find the reason for the issue in the first place. I'd like some help figuring out what can be done.
5 Comments
Walter Roberson
on 26 Oct 2025
Just to confirm:
When you downloaded the file into a folder that you are working in, is the folder you are working in part of OneDrive?
Victor
on 26 Oct 2025
I feel your pain...the OneDrive stuff causes me no end of headaches as well trying to figure out where stuff got put that didn't remember to override the stupid default location...
Some thoughts/questions...
- Any chance the new folder was hidden?
- Any chance the new folder location is in one of the protected areas so you would need Admin privileges to create it?
- Will MATLA dir() locate the original moved files?
- What about the OS dir? (!dir *.m) or use full path.
How did you do the download? I found with some shared files the packaged interface had actually created links to the originals, not physical copies. I don't recall now how I did get them to be local; I may have reverted to opening the shared original and manually saving it to the physical drive---these were mostly MS-Office files; I've scrupulously avoided ever letting any MATLAB-related files get out of the barn after discovering there's apparently no way to map the one drive location so make it appear local and MATLAB didn't seem to have any way to be able to create a path to them that couuld use, much like your issue with some .mat files that inadvertently got copied up to the OneDrive folder. It doesn't help there are multiple of those depending upon whether it's the college network or personal machine which makes for even more confusion.
Victor
on 27 Oct 2025
Image Analyst
on 27 Oct 2025
When you go to File Explorer and look at the One Drive source folder, does it have a white check mark in a green circle next to the file names.

This means you're telling OneDrive to always keep a local copy. If it's not checked then the only copy (if you haven't accessed the file in a while) will be on the OneDrive server in the cloud. And perhaps there's some kind of delay in downloading the file from the cloud from the time you try to paste it until it actually gets there. Click on the cloud in the lower left task tray of your task bar and see if it says "Your files are synced."
To make sure you always have files on your local hard or SS drive, right click on the folder that you want to always keep local and select "Always keep on this device". I think that should apply to all the files within the folder too. You should see green checkmark circles when it's done.
Accepted Answer
More Answers (0)
Categories
Find more on File Operations 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!