How to locate and record the folder number that exceeds user defined value in a directory?

조회 수: 3 (최근 30일)
I have multiple folders in increasing order of last 4 digits in the directory as r1_0.05, r1_0.10, r1_0.15, r1_0.20...... In each folder I have multiple files but I am interested in one of file that is value.out. I want to run a loop in each folder of directory to find the folder that exceeds the user defined value (in my case 0.01). Once I found the folder that exceed 0.01 value, I want to record the last 4 digit of that folder in the matrix form. For example, say the user defined value just exceed in the folder r1_0.20 then I want to record the folder 4 digit and terminate the loop. Any idea is appreciated.

답변 (1개)

Image Analyst
Image Analyst 2019년 3월 2일
Have you tried to parse the folder name like
underlineLocation = strfind(folderName, '_');
theNumber = str2double(folderName(underlineLocation:end))
if theNumber > someThresholdNumber
% Do something
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by