Upload every n file to matlab

2 vues (au cours des 30 derniers jours)
Hussein Kokash
Hussein Kokash le 18 Juin 2021
Commenté : Hussein Kokash le 18 Juin 2021
Hello all,
I have the following script that I use to upload text files to Matlab, I want to edit it so I can skip 10 files when uploading, i.e select the 1st file, skip 10 select the 2nd, etc. so I will end up with (1, 11, 21, 31) for example. is there a way that I can do that in Matlab?
Thank you, appreciate it.
[file_list, path_n] = uigetfile('.txt', 'Multiselect', 'on');
filesSorted = natsortfiles(file_list);
if iscell(filesSorted) == 0;
filesSorted = (filesSorted);
end
for i = 1:length(filesSorted);
filename = filesSorted{i};
data = load([path_n filename]);
x = data (:,1);
y = data (:,2);
end

Réponse acceptée

KSSV
KSSV le 18 Juin 2021
[file_list, path_n] = uigetfile('.txt', 'Multiselect', 'on');
filesSorted = natsortfiles(file_list);
if iscell(filesSorted) == 0;
filesSorted = (filesSorted);
end
for i = 1:10:length(filesSorted); %<-- change loop index here
filename = filesSorted{i};
data = load([path_n filename]);
x = data (:,1);
y = data (:,2);
end
  1 commentaire
Hussein Kokash
Hussein Kokash le 18 Juin 2021
Yup, that is it.
Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by