How to get the matrix when I need a logic matrix

1 回表示 (過去 30 日間)
PRED LIU
PRED LIU 2020 年 5 月 21 日
コメント済み: Steven Lord 2020 年 5 月 21 日
How to get a matrix QQQQ when I need a logic matrix AAAA
AAAA=[
true true true true false true true
true true true true false true true
true true true true false true true
true true true true false true true
]
y=[
0.0246 0.4415 0.0274 0.0269 0.0264 0.0255 0.0557
0.4535 0.0260 0.4495 0.4455 0.0563 0.0566 0.0569
0.0251 0.0542 0.0545 0.0548 0.0551 0.0554 0.0563
1.0000 0.1615 0.0061 0.0156 0.0692 0.1323 0.0001
]
QQQQ
[
0.0246 0.4415 0.0274 0.0269 0 0.0255 0.0557
0.4535 0.0260 0.4495 0.4455 0 0.0566 0.0569
0.0251 0.0542 0.0545 0.0548 0 0.0554 0.0563
1.0000 0.1615 0.0061 0.0156 0 0.1323 0.0001
]

採用された回答

David Hill
David Hill 2020 年 5 月 21 日
QQQQ=AAAA.*y;
  1 件のコメント
Steven Lord
Steven Lord 2020 年 5 月 21 日
That works as long as all elements in y are finite.
Inf*false
I'd use logical indexing.
QQQQ = zeros(size(y));
QQQQ(AAAA) = y(AAAA);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by