Cannot access files in path or current folder

I have files in matlab files in 'F:\Matlabb_files' folder.This folder is the current folder and this folder plus all its subfolder are in the path,but i cannot access the files directly when i press 'Run' command.I tried to manually delete and add these folders using the GUI but also it didn't help.I tried to add these using 'addpath' command,'userpath' command and 'savepath' commands.In 'pathdef.m' files,i can see all the newly added files,but while running,it always throws the same error 'File not found in current folder or MATLAB path'
I tried to press 'Change folder' and 'Add to path' option on every run,but it poped up everytime.
Please help me how to stop this error.

11 Comments

Hypothetically, there could be security restrictions on the folder that are interfering.
What shows up for
fileattrib('F:\Matlabb_files')
I got this:
fileattrib('F:\Matlabb_files')
Name: 'F:\Matlabb_files'
archive: 0
system: 0
hidden: 0
directory: 1
UserRead: 1
UserWrite: 1
UserExecute: 1
GroupRead: NaN
GroupWrite: NaN
GroupExecute: NaN
OtherRead: NaN
OtherWrite: NaN
OtherExecute: NaN
Is this a problem?
Are you calling a function that's changing the Matlab current folder?
No. You can see the code for the function alternate in the first image. It just has a function header and does a disp() and then has an end statement.
@Walter Roberson Yeah, I saw that, but I thought maybe this error was not produced by alternate.m particularly, rather by another function in the same folder.
I tried to to be simple,so i wrote a simple function to explain my problem.This is the case for all scripts in all folders.And also,there is no file that changes the path or with name that override matlab functions.
I fail to see another reason apart from a script or function changing the current folder. Maybe having a second look at your scripts to make sure would be useful. Good luck.
They are getting the message before the functions are executed. They respond with "Yes, change directory" and that will run the function once, but if they then ask to run the exact same function a second time, it will tell them again that the function is not on the path.
It has to be something strange about security measures (like anti-virus), or complex security settings... or maybe MATLAB doesn't like being one level down from the root.
Long shot here:
Please check to be sure that the F: drive has 8.3 filesystem names enabled.
@Walter Roberson You caught my problem exactly.when i run the function again it shows the message again.what do you mean by '8.3 filesystem' ?

Sign in to comment.

Answers (1)

Hello, I've encountered the same problem (working with Matlab 2020a), and I went for "Home - Preferences - Current Folder" and clicked "Restore Default Settings", then I clicked "General - Toolbox path caching" and clicked "Update Toolbox Path Cache", and it magically worked. When I ran the file again there was not error reported. I'm not sure which step did the job but that's what I did. Hope it's helpful.

Categories

Products

Release

R2021a

Asked:

on 16 Aug 2021

Answered:

on 2 Mar 2023

Community Treasure Hunt

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

Start Hunting!