MATLAB unable to find files
66 views (last 30 days)
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
Image Analyst
37 minuter ago
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
Victor
on 28 Oct 2025 at 20:40
Moved: Walter Roberson
ungefär 20 timmar ago
1 Comment
dpb
on 28 Oct 2025 at 22:38
Moved: dpb
ungefär 9 timmar ago
Read about <What is MATLAB search path?> and how to set an additional folder on startup. Or, you can use the Settings dialog to define and save the revised MATLABPATH. You definitely don't have to do this manually every time.
My general practice is to have a specific working directory for current work and add it to the top of the search path and have that saved
More Answers (0)
See Also
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!