User input file directory
이전 댓글 표시
I am writing a script that reads all of the files of a certain type in a given directory, and I'm wondering if there is a way to allow the directory location to be a user input.
Currently the code looks like:
directory_in = dir('C:\Folder\Bob\*.dat');
I would like to change it to something more like:
input_in = input('Enter the directory name: ');
directory_in = dir(input_in, '*.dat');
I know this code won't work as written for multiple reasons, but I'm wondering if there is some way I could combine the user input with the file type suffix in order to minimize the amount of editing a future user would need to perform on the script.
채택된 답변
추가 답변 (2개)
Azzi Abdelmalek
2016년 7월 26일
0 개 추천
Use uigetdir
Bob Thompson
2016년 7월 27일
0 개 추천
댓글 수: 4
Star Strider
2016년 7월 27일
That function seems to be a File Exchange contribution, since I can’t find it in the documentation.
The uigetfile is the only built-in function that seems to be close to it.
Bob Thompson
2016년 7월 27일
편집: Bob Thompson
2016년 7월 27일
Image Analyst
2016년 7월 27일
I don't understand. Do you not trust the users to pick the proper files? If not, then you can use dir() to specify the proper file pattern once they've chosen the folder via any of the other functions (uigetdir, uigetfile, or uipickfiles).
Bob Thompson
2016년 7월 28일
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!