Dir function gives nothing
10 ビュー (過去 30 日間)
古いコメントを表示
Zeynab Mousavikhamene
2019 年 11 月 16 日
コメント済み: Zeynab Mousavikhamene
2019 年 11 月 16 日
I am using Dir function to find the specific files that have cell in their names but it retunrs nothing although cell files are existing in that folder. Here is the code:
selpath = uigetdir;
struct = dir([selpath '*cell*.json']);
and here is the sample image of the folder:
![1.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/248629/1.jpeg)
2 件のコメント
Stephen23
2019 年 11 月 16 日
Concatenating strings to create the filename is the problem.
Use fullfile instead, your code will work fine.
採用された回答
Walter Roberson
2019 年 11 月 16 日
selpath = uigetdir;
if isempty(selpath); return; end %user cancel
dinfo = dir(fullfile(selpath, '*cell*.json'));
uigetdir() does not promise that what it returns will end with a directory separator, so use fullfile()
Using struct as a variable name would interfere with creating structures.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!