How to resample n vectors with specified length from a longer vector

2 ビュー (過去 30 日間)
Levente Gellért
Levente Gellért 2021 年 2 月 24 日
回答済み: Levente Gellért 2021 年 2 月 24 日
Hi All,
I would like to randomly select n sections (let's say 1000 times) of given length from a longer vector. With the in-built re-sampling functions I can not specify the length of the sections. Sections can overlap.
I do not have initiative at all.
Many thanks!
lg

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 24 日
starts = randperm(length_of_vector-length_of_section+1, n).';
subsets = cell2mat(arrayfun(@(S) vector(S:S+length_of_section-1), starts, 'uniform', 0));
Each row of subsets will be a different sample.

その他の回答 (1 件)

Levente Gellért
Levente Gellért 2021 年 2 月 24 日
Dear Walter, great thanks.
Regards!
lg

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by