Upload every n file to matlab
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
KSSV
on 18 Jun 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
More Answers (0)
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!