How to get the matrix when I need a logic matrix

1 visualizzazione (ultimi 30 giorni)
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
]

Risposta accettata

David Hill
David Hill il 21 Mag 2020
QQQQ=AAAA.*y;
  1 Commento
Steven Lord
Steven Lord il 21 Mag 2020
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);

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by