Logical operations on logical matrices?

5 ビュー (過去 30 日間)
Corymbiamaculata
Corymbiamaculata 2019 年 3 月 12 日
コメント済み: Corymbiamaculata 2019 年 3 月 12 日
I have a 3-dimensional matrix with logical values, A, sized 3000 x 4000 x n, where n varies depending on iteration, but is usually between 1 and 10.
I'm trying to create a 2-dimensional matrix with logical values, B, sized 3000 x 4000, where a given element would be set to 'true' if any of the corresponding elements in A (same row and column, any n) is 'true', or to 'false' in other cases (i.e. when all corresponding elemnents in A are 'false').
I'm sure there is a way to do it without a loop by row/column or switching back and forth between logicals and integers. Thanks in advance for help!
  1 件のコメント
KSSV
KSSV 2019 年 3 月 12 日
YOu can straight awaya extract the values with logicals.....
if A is your matrix and idx is your logical with same size as A...A(idx) gives you elements where idx == 1 i.e true.

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

採用された回答

Image Analyst
Image Analyst 2019 年 3 月 12 日
Use any
b=any(A, 3)
  1 件のコメント
Corymbiamaculata
Corymbiamaculata 2019 年 3 月 12 日
Thank you!!!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by