How to Check if array has multiples of a value and how to replace those values that are multiples with a certain assigned values
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is the Question:
- Check each value in the Z array to see if it is a multiple of 8. If an element is a multiple of 8, assign -6 to that element.
- The only thing you are to display in the Command window is the Z array values.
T
if mod(Z(m),8)==0 && mod(Z(m),8)==0
Z(m,n)=-6
end
Z
ans=
4 6 8 0
6 8 10 0
8 10 12 42
0 0 105 -6
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!