Dir function gives nothing
조회 수: 9 (최근 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:
댓글 수: 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!