필터 지우기
필터 지우기

How to process multiple sub - folders in main folder

조회 수: 4 (최근 30일)
Wen Jun Chua
Wen Jun Chua 2020년 3월 25일
편집: Wen Jun Chua 2020년 3월 26일
Hi,
I'm currently in the process of processing data from 5 files within a folder. I have 1 main folder containing 8 subfolders, each containing 5 files. Right now im already able process the files within 1 single sub-folder to how i want. However I want to be able to process the each individual subfolder(Data type analysised is same for all subfolders). Sub folders are called (70ml, 80ml....).
Code: (For 1 sub-folder)
cd 'C:\Hello\A.......\70ml'; (Main Folder called 'C:\Hello\A' containing 'C:\Hello\A.......\70ml', 'C:\Hello\A.......\80ml' etc)
files = dir('*r.png');
compiledArr = zeros(8,5)
for i = 1:size(files)
filename = string(files(i).name);
imread(filename);
SummaryPage = imread(filename);
J = imresize(SummaryPage, 4);
roi = [1589 528 1376 1368];
ocrResults = ocr(J, roi);
for LC = 1:8
wordCells = ocrResults.Words;
tempStr = wordCells(LC);
tempStr = strrep(tempStr,",","");
tempNum = str2double(tempStr)
valArr(LC, 1) = tempNum
end
switch i
case 1
compiledArr(:, i) = valArr
case 2
compiledArr(:, i) = valArr
case 3
compiledArr(:, i) = valArr
case 4
compiledArr(:, i) = valArr
case 5
compiledArr(:, i) = valArr
end
end
Do you have any suggestions on how this could be done? Thank you!

답변 (1개)

Rashedur Rahman
Rashedur Rahman 2020년 3월 26일
Try this code please.
You should check the following link also
  댓글 수: 1
Wen Jun Chua
Wen Jun Chua 2020년 3월 26일
편집: Wen Jun Chua 2020년 3월 26일
Hi, i tried the code and repace with my own directories and such but i now have an error called
Index exceeds the number of array elements (1).
at this line tempStr = wordCells(LC);
Could it be because of i hardcoded at the switch part? any suggestion on improvement i can do

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by