MATLAB unable to find files

37 views (last 30 days)
Victor
Victor on 26 Oct 2025 at 0:02
Edited: dpb on 26 Oct 2025 at 15:13
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.
  3 Comments
Victor
Victor 1 minute ago
No, the folder that I am working on is stored locally on my laptop. Sorry for the confusion.
dpb
dpb about 3 hours ago
Edited: dpb about 3 hours ago
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...
  1. Any chance the new folder was hidden?
  2. Any chance the new folder location is in one of the protected areas so you would need Admin privileges to create it?
  3. Will MATLA dir() locate the original moved files?
  4. 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.

Sign in to comment.

Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!