Multiply Even Variables in an Array

6 vues (au cours des 30 derniers jours)
Richard Dillenson
Richard Dillenson le 23 Fév 2021
Commenté : Steven Lord le 24 Fév 2021
I have initialized an array with values.
I have made a function that will determine if the integers within the array are odd or even. For the integers that are even, I want to multiply them by a set, finite number such as 5.
How would I do this?

Réponses (1)

Steven Lord
Steven Lord le 23 Fév 2021
Hint: use logical indexing twice in the onle line of code that performs this replacement.
  8 commentaires
James Tursa
James Tursa le 24 Fév 2021
This is not correct. You need to use the exact same indexing on both sides of the assignment.
Steven Lord
Steven Lord le 24 Fév 2021
There are also mismatched parentheses. From the fact that Richard Dillenson said "Thank you" I assume that's an error when the solution was copy-and-pasted into Answers not an error in the code they ran.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown 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