Plot a binary value each time a number in vector A is also present in vector B.

4 ビュー (過去 30 日間)
Carlos Goncalves Moreira
Carlos Goncalves Moreira 2018 年 7 月 16 日
回答済み: Matt J 2018 年 7 月 17 日
I have two vectors of different sizes: A=5000x1 and B=86000x1. They both represent time in seconds, but A shows important timestamps while B shows all seconds in my observation window.
I was wondering how I can calculate a binary Result vector where 1 will mark each of the seconds in B that were stamped in A, and 0 will mark all the remaining seconds. I realised A could also work as a vector showing indexes, since B is a continuous vector 1:86000, if that helps.
I am struggling with this problem, that doesn't look very complex but it's eating my brain. Thanks!
  1 件のコメント
Carlos Goncalves Moreira
Carlos Goncalves Moreira 2018 年 7 月 17 日
I Actually solved this question already. I have created a 86000x1 vector of zeros and tranformed all the indexes stated in vector A into ones. It was easy. Thanks anyway.

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

回答 (1 件)

Matt J
Matt J 2018 年 7 月 17 日
Or you could use ismember,
result = ismember(B,A);

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by