Effacer les filtres
Effacer les filtres

Using logical operator and maintaining array size

1 vue (au cours des 30 derniers jours)
SJ Won
SJ Won le 4 Juil 2019
Commenté : SJ Won le 4 Juil 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.

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 4 Juil 2019
Modifié(e) : KALYAN ACHARJYA le 4 Juil 2019
Why logical? its simple multiplication.
>> x.*y
ans =
0 0 6 6 8
  2 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 4 Juil 2019
OK?
SJ Won
SJ Won le 4 Juil 2019
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by