if greater than in for loop
92 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
using a for loop and if statement, i need to subtract 25 from each element in a vector called "seven" that is greater than 100.
here is my code, but when i run it i get the original values of all elements in seven. how can i fix this?
for k = seven
if k > 100
k - 25
else
k + 0
end
end
0 commentaires
Réponse acceptée
Plus de réponses (1)
Rafael Hernandez-Walls
le 26 Juin 2020
seven=(seven>100).*(seven-25)+(seven<=100).*seven;
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!