unable to make directory in specified folder
조회 수: 15 (최근 30일)
이전 댓글 표시
I have an issue using mkdir to create a folder to save my data.
datadir=fullfile('D:','Users','10513345');
cleandir=[datadir filesep 'data_refmast_512samplerate_71chan'];
if exist(cleandir,'dir')~=7
mkdir(cleandir);
end
The error I receive is: Error using mkdir
The system cannot find the file specified.
I have also tried just manually adding the folder and continue my code however later on it won't recognize this slef-made folder as a file or directory to put save the data.
So, im not really sure where in the progress matlab doesn't recognize the directory.
댓글 수: 1
Rashed Mohammed
2021년 3월 25일
편집: Rashed Mohammed
2021년 3월 25일
Hi mitchell
Have you tried this on a different location such as different folder in D: other than 'Users' or a completely different drive other than D:?
답변 (1개)
per isakson
2021년 4월 27일
편집: per isakson
2021년 4월 27일
"it won't recognize this slef-made folder" Did you add it to Matlab's search path? ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/598240/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/598240/image.png)
On my system, R2018b,Win10, your script works as expected. (There was no directory named Users on D: in advance.)
%%
datadir = fullfile( 'D:', 'Users', '10513345' );
cleandir = fullfile( datadir, 'data_refmast_512samplerate_71chan' ); % stick to fullfile
if exist(cleandir,'dir')~=7
mkdir(cleandir);
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/598195/image.png)
Running the script a second time also worked as expected. i.e. did nothing.
Repacing D: by Z: (Z: doesn't exist) and running the script throws the error
Error using mkdir
The system cannot find the path specified.
Error in Untitled2 (line 5)
mkdir(cleandir);
Did mkdir really throw the error
The system cannot find the file specified.
There is no file involved.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Name Construction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!