フィルターのクリア

sampling pairs of elements

3 ビュー (過去 30 日間)
María Jesús
María Jesús 2015 年 2 月 27 日
回答済み: Guillaume 2015 年 2 月 28 日
Hi,
I'm trying to sample data from two vectors simultaneously, one is a population value and the other a point in time. I need to get the data to be sampled as a pair, that is, I need to be able to sample the population and retain the time at which it occurs. Is there a way to do that?
Thanks!

回答 (2 件)

dpb
dpb 2015 年 2 月 27 日
Select the sample from the indices 1:length(vector) and the use that to select the elements.
  2 件のコメント
María Jesús
María Jesús 2015 年 2 月 28 日
I'm not sure I understand... could you elaborate?
Guillaume
Guillaume 2015 年 2 月 28 日
編集済み: Guillaume 2015 年 2 月 28 日
@dpb, numel is better than length since the latter can return the size of different dimensions with matrices). I'm of the opinion that length should never be used.

サインインしてコメントする。


Guillaume
Guillaume 2015 年 2 月 28 日
One simple way:
popvalues = [1 5 8 10 3 6 8 9 10 54 23 1]; %for example
poptimes = [4 10 16 14 12 18 20 24 22 2 6 8]; %for example
for sample = [popvalues; poptimes]
%do something with sample
%...
end

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by