select 20 percent between two values

2 ビュー (過去 30 日間)
Simone de Winter
Simone de Winter 2020 年 4 月 2 日
編集済み: Adam Danz 2020 年 4 月 3 日
Hi All,
I have a lot of recordings to anlyze, but not enough time to go through the whole of them. Now I would like MATLAB to randomly select 20% of each recording. So what I want in the end is to create a function, that I can set my directory to all the recordings, and than for each 20% percent is randomly selected and put into a new wav. file that I can use for the analyses. I looked at examples of random sampling, but could not find anything like this. Is this possible to do in MATLAB?
Cheers,
Simone

回答 (1 件)

Adam Danz
Adam Danz 2020 年 4 月 2 日
編集済み: Adam Danz 2020 年 4 月 3 日
Use y = randsample(n,k) to select k random elements from a vector 1:n.
% recordingList is an array that contains all of your recordings.
randIdx = randsample(numel(recordingList), round(numel(recordingList)*.2));
sample = recordingList(randIdx);

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by