Dir function gives nothing
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Zeynab Mousavikhamene
il 16 Nov 2019
Commentato: Zeynab Mousavikhamene
il 16 Nov 2019
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 Commenti
Stephen23
il 16 Nov 2019
Concatenating strings to create the filename is the problem.
Use fullfile instead, your code will work fine.
Risposta accettata
Walter Roberson
il 16 Nov 2019
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!