How to use if statement with an array
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nicholas Wills
le 19 Mar 2017
Réponse apportée : Star Strider
le 19 Mar 2017
I want to find out if an array equals a particular set of values, as follows:
if arrayName=[0 1 1 0]
do this
end
And so on, MATLab throws up an error saying it expects a scalar value. Am I using the brackets wrong, or is this something that cannot be done? (I am quite new to MATLab).
Cheers, Nick
0 commentaires
Réponse acceptée
Star Strider
le 19 Mar 2017
There are several set functions that could apply to your problem. One that comes quickly to mind is ismember with the 'rows' option.
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!