Checking values in a vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jose Grimaldo
le 15 Fév 2020
Modifié(e) : David Goodmanson
le 16 Fév 2020
Im trying to check a vector, that after the third integer the rest of the values should be equal to zero. If there is value that is not equal to zero, I should end the program. Im trying to do it without using loops.
I try doing this but it does not check the values. What can I Do?
x=[5 9 0 0 0 01]
if x(4:end)~=0
error('Invalid values entered. Program Terminated');
end
0 commentaires
Réponse acceptée
David Goodmanson
le 16 Fév 2020
Modifié(e) : David Goodmanson
le 16 Fév 2020
Hello Jose
if any(x(4:end)~=0)
(do something)
else
(do something else)
end
0 commentaires
Plus de réponses (0)
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!