How to make two seperate list of files from one list of files?

4 vues (au cours des 30 derniers jours)
Tomaszzz
Tomaszzz le 24 Jan 2022
Commenté : Tomaszzz le 24 Jan 2022
Hi all,
I have mutiple folders including 15 mat files (image below). The files are srtructures with mutiple tables inside.
I want to process in a loop files highlighted green using an operation and files highlighted red using a diffrent operation. The last three digits in the files name may differ depending on the folder.
I want to omit files that are not highlighted.
For this purpose, I want to make two seperate list of files and this is where I fail. Please help
%% List all files in the folder
all_files = dir(fullfile(Folder, '*.mat'));
%% List files highlighted green and red
green_files = all_files (2,3,7,8,12,13)
red_files = all_files (4,5,9,10,14,15)
Error: Index in position 2 exceeds array bounds (must not exceed 1).
%% Loop through each list of files
for k = 1:length(green_files)
operation 1
end
for k = 1:length(red_files)
operation 2
end

Réponse acceptée

Stephen23
Stephen23 le 24 Jan 2022
all_files = dir(fullfile(Folder, '*.mat'));
green_files = all_files([2,3,7,8,12,13])
red_files = all_files([4,5,9,10,14,15])

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by