Borrar filtros
Borrar filtros

How to process multiple sub - folders in main folder

1 visualización (últimos 30 días)
Wen Jun Chua
Wen Jun Chua el 25 de Mzo. de 2020
Editada: Wen Jun Chua el 26 de Mzo. de 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!

Respuestas (1)

Rashedur Rahman
Rashedur Rahman el 26 de Mzo. de 2020
Try this code please.
You should check the following link also
  1 comentario
Wen Jun Chua
Wen Jun Chua el 26 de Mzo. de 2020
Editada: Wen Jun Chua el 26 de Mzo. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by