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?

4 次查看(过去 30 天)
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.

采纳的回答

WAT
WAT 2015-9-25
编辑:WAT 2015-9-25
Try
V_sum = sum(V1(V1 > N));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Licensing on Cloud Platforms 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by