Using logical operator and maintaining array size
3 次查看(过去 30 天)
显示 更早的评论
Say I have x = [ 0 0 1 1 1] and y = [ 4 3 6 6 8]
How do I use logical operator so that I maintain the array size? I want the result to say [ 0 0 6 6 8] - so if it's false then make them zero but keep the rest. I'm trying to avoid if or for loops if possible.
0 个评论
采纳的回答
KALYAN ACHARJYA
2019-7-4
编辑:KALYAN ACHARJYA
2019-7-4
Why logical? its simple multiplication.
>> x.*y
ans =
0 0 6 6 8
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!