How to get the matrix when I need a logic matrix
1 次查看(过去 30 天)
显示 更早的评论
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
]
0 个评论
采纳的回答
David Hill
2020-5-21
QQQQ=AAAA.*y;
1 个评论
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 Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!