Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to select a bunch of files from a set of files?

1 回表示 (過去 30 日間)
Heramb Gaikwad
Heramb Gaikwad 2019 年 12 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Dear friends,
I have 50 *.std files and I want to select bunch of 5 files at a time for further process and so on up to 50 files. Kindly guide me in this regards....
Waiting for quick response.
Thank you

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 12 月 21 日
projectdir = 'NameOfDirectoryFilesAreIn';
dinfo = dir( fullfile(projectdir, '*.std'));
filenames = fullfile( projectdir, {dinfo.name});
Nfiles = length(filenames);
randorder = randperm(Nfiles);
groups_of_5 = reshape(filenames(randorder), 5, []);
Now groups_of_5 is a cell array of character vectors with 5 rows and 10 columns. groups_of_5(:,K) is a cell array of the K'th group.

Heramb Gaikwad
Heramb Gaikwad 2019 年 12 月 21 日
Dear Sir,
Thank you or your quick reply
  1 件のコメント
Heramb Gaikwad
Heramb Gaikwad 2019 年 12 月 25 日
Dear Sir
I have tried following program and got the result.
Dir='XXX\'; %selects particular directory%
data = [Dir,'*.std']; %selects .std files from the directory%
Data = ls(data); %lists the .std files%
[r,c] = size(Data); %determines the size (rows X column)%
files = Data(1:r,1:c); %stores file names%
for i = 1:10
j = (((i-1)*5+1):(i*5));
aa = []; %Blank matrix%
for k = j(:,1):j(:,end) %k varies from 1 to i%
% calculation %
end
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by