Filter löschen
Filter löschen

How to process multiple sub - folders in main folder

4 Ansichten (letzte 30 Tage)
Wen Jun Chua
Wen Jun Chua am 25 Mär. 2020
Bearbeitet: Wen Jun Chua am 26 Mär. 2020
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!

Antworten (1)

Rashedur Rahman
Rashedur Rahman am 26 Mär. 2020
Try this code please.
You should check the following link also
  1 Kommentar
Wen Jun Chua
Wen Jun Chua am 26 Mär. 2020
Bearbeitet: Wen Jun Chua am 26 Mär. 2020
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by