MATLAB Answers

How to make a script so I can choose a file from folders

조회 수: 13(최근 30일)
Luís Mira
Luís Mira 3 Apr 2021
답변: dpb 4 Apr 2021
I'm in my last year of graduation and I'm doing a research project about space weather. To summarize, I've some data distributed by several folders. There are many folders inside each one and I have to build a script to pick each folder content. How should I do it?


dpb 4 Apr 2021
While it's only documented by a very terse example, the builtin dir function will recurse directories if the search pattern contains "**/" preceding the pattern given for the file match itself.
That is,
will return all Excel files of the explicit .xlsx type from the current directory and all subdirectories below. Giving a specific top level directory of the data storage location in combination with the wildcard will give you the full structure below that location.
You'll also want to explore fullfile and fileparts in processing the results and in preparing the input filename strings.




Community Treasure Hunt

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

Start Hunting!

Translated by