randomly picking some files
Show older comments
I want to pick some .wav files randomly from a certain directory without replacement or with no repititions .. how is that possible ? please help me in this regard
Accepted Answer
More Answers (2)
Azzi Abdelmalek
on 10 Sep 2013
your_folder='E:\matlab';
d=dir([your_folder '\*.wav']);
f={d.name};
n=numel(f);
idx=randi(numel(f));
file=f{idx}
f(idx)=[];
2 Comments
jalal Ahmad
on 11 Sep 2013
sabrina lenglet
on 14 Jun 2017
How can I play this sound or file.wav ? thanks
Walter Roberson
on 10 Sep 2013
Yes. If your file names are in the cell array FileNames then
shuffleidx = randperm(length(fileNames));
for K = 1 : length(suffleidx)
thisfile = fileNames{shuffleidx(K)}
...
end
Categories
Find more on Digital Input and Output 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!