comparing double array to logical array

8 ビュー (過去 30 日間)
Engineer Undergoing
Engineer Undergoing 2021 年 8 月 9 日
Hello
I am trying to compare two arrays and the save the results in a new one (third), the first array is 1000x1 double array and the second array is 1000x1 logical array. I'd like to compare them to each other, meaning for every true value (1) in the logical array I'd get the corresponding value of the double array (first array) saved in the new array (third array).
How can I do that? I tried looking up for that on the " Relational Operations" but I could'nt find something relevant, Should I do an if condition statement and how?
  2 件のコメント
Engineer Undergoing
Engineer Undergoing 2021 年 8 月 9 日
Thanks for the good reference!

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 9 日
result = DoubleArray(LogicalArray);
Logical indexing.
  1 件のコメント
Engineer Undergoing
Engineer Undergoing 2021 年 8 月 9 日
worked like a charm, I didn't expect it to be this simple
Thanks

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by