trying to use the dir / cd(dir) function, "error using cd. unable to change current folder to...(name is nonexistent or not a folder)" message appears
Show older comments
Hi
I am working on an assignment and the first question asks to define the directory. The function I am having trouble with is dir and cd(dir). I am using the live editor function on the online version of Matlab. After following the instructions provided to me from my prof, I end up with this message ""error using cd. unable to change current folder to '/MATLAB Drive/C: \Users\X\Documents\school\Labdata.xlsx'. (name is nonexistent or not a folder). X is just my name. My code is this:
dir = 'C: \Users\X\Documents\school\Labdata.xlsx' ;
cd(dir)
Can someone please explain why I am having this issue and how I can resolve it? Thank you in advance!
1 Comment
dir = 'C: \Users\X\Documents\school\Labdata.xlsx' ;
% ^ invalid path name
% ^^^^^^^^^^^^ cannot CD to a file
%^^ variable name is best avoided
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!