Using logical operator and maintaining array size
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
SJ Won
am 4 Jul. 2019
Kommentiert: SJ Won
am 4 Jul. 2019
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 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 4 Jul. 2019
Bearbeitet: KALYAN ACHARJYA
am 4 Jul. 2019
Why logical? its simple multiplication.
>> x.*y
ans =
0 0 6 6 8
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!