How can I sum all elements of a defined vector 'V' that are greater than a scalar value of 'N', that is also pre-defined?

3 vues (au cours des 30 derniers jours)
I have created mock variables for 'V1' and 'N', and my code goes as follows:
if V1 > N V_sum = sum(V1)
I would not be surprised if I am missing something that is blindingly obvious, but any help is greatly appreciated.

Réponse acceptée

WAT
WAT le 25 Sep 2015
Modifié(e) : WAT le 25 Sep 2015
Try
V_sum = sum(V1(V1 > N));

Plus de réponses (0)

Catégories

En savoir plus sur Licensing on Cloud Platforms dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by