unable to make directory in specified folder

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
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
per isakson 2021 年 4 月 27 日
編集済み: per isakson 2021 年 4 月 27 日

1 投票

"it won't recognize this slef-made folder" Did you add it to Matlab's search path?
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
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.

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

質問済み:

2021 年 3 月 22 日

編集済み:

2021 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by