Processing mutiple txt files from subfolders
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I am new to Matlab and so would like to ask for your help in modifying a routine:
Under this current routine, I am required to input individual txt files placed in specific folder directories and run the function. Naturally, all analyses results are saved in the same folder containing the txt file. Then, to process the others I need to move to another folder and rerun the routine. This proves to be really time consuming since I have quite a lot of samples and references to run...
Is there a way to modify the routine so that I can simply input a folder, then it will search for all the txt files placed in the subfolders, apply the Wavelet analysis on each one of the txt files, and save each analysis result (matrices, images, fig files) to the subfolder containing the txt file?
I tried consulting these threads: https://fr.mathworks.com/matlabcentral/answers/245959-how-to-read-text-files-from-different-sub-folders-in-a-folder
and modified the "input ascii file" section of the routine above, to no avail...
I hope my problem is clear enough. I'd appreciate any advice/help, thanks in advance!
댓글 수: 0
답변 (1개)
Image Analyst
2017년 4월 2일
You can use dir() with two asterisks if you have a later version of MATLAB. See attached demo. If you don't then you can use genpath() to get files in all subfolders. I've attached a demo for that too.
댓글 수: 2
Image Analyst
2017년 4월 3일
Post your code. You did something else. That line of code was line 43 in my demo, not line 17 like you had. Anyway, I changed that line to *.txt and it worked beautifully. You must have messed it up some other way.
And if anything before line 17/43 has wavelet stuff in it, I can't run that since I don't have the wavelet toolbox.
참고 항목
카테고리
Help Center 및 File Exchange에서 Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!