Upload every n file to matlab

1 次查看(过去 30 天)
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

采纳的回答

KSSV
KSSV 2021-6-18
[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

更多回答(0 个)

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by