how to return only true statements
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tristan
le 27 Sep 2013
Commenté : Azzi Abdelmalek
le 27 Sep 2013
for example, if I have:
>> e=[1 -7 -1.2 6 -9 19 1.8]
and I want matlab to give me only the true statements for e>0
as in:
e=[1 6 19 1.8]
I tried
>> if e>0 e end
but doesn't do anything.
thanks
1 commentaire
Azzi Abdelmalek
le 27 Sep 2013
Modifié(e) : Azzi Abdelmalek
le 27 Sep 2013
I think you should read the basics of programming. (not necessary Matlab)
if e>0
e
end
What are you expecting when you write
e
Réponse acceptée
Plus de réponses (1)
Wayne King
le 27 Sep 2013
Just do
e>0
You get the following
1 0 0 1 0 1 1
If you want to return the elements
X = e(e>0);
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with MATLAB 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!