How do I do greater than and less than in the same command then find the size?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lora Priest Dutheil
le 24 Avr 2016
Commenté : Lora Priest Dutheil
le 25 Avr 2016
I need to find the number of values that fall between two values, i.e. number of seisms that were between 7 and 8 magnitude, out of 11655 total values. size(7<=mag<=8)
0 commentaires
Réponse acceptée
Plus de réponses (1)
Roger Stafford
le 24 Avr 2016
This is very elementary matlab. Assuming 'mag' is a vector, do this:
count = sum((7<=mag)&(mag<=8));
5 commentaires
Roger Stafford
le 25 Avr 2016
@Lora: It takes ingenuity to make an innocuous line like
count = sum((7<=mag)&(mag<=8));
give rise to an error message. Let me think of the ways.
1) An incomplete copy leading to unbalanced parentheses;
2) Naming a variable 'sum';
3) Failing to evaluate 'mag' in advance;
4) Having 'mag' be non-numeric and incomparable with numbers.
What exactly did your error message state, and did it actually refer to the above line?
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!