フィルターのクリア

Extracting valid elements from a vector to another

1 回表示 (過去 30 日間)
Andreas Volden
Andreas Volden 2014 年 10 月 6 日
コメント済み: Andreas Volden 2014 年 10 月 6 日
Hi! I've been struggling with this problem for a while now, and now I've gotten kinda blind for a solution. I have a vector A of length n and a vector B of length i, where n > i. Vector A contains measured samples and vector B contain elements that indicate which samples in vector A that is valid in an incrementing order. Maybe an example would illustrate this better:
A(1:n) = [5 6 3 4 5 ...] and B(1:i) = [2 3 5 10 ...] I want to extract valid values of A into a third vector of length i, say vector C(1:i), based on element values of B. In above case C = [6 3 5 ....]
Any help would be appreciated, particularly some coding hint/tips!

採用された回答

Guillaume
Guillaume 2014 年 10 月 6 日
It's simply:
C = A(B);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by