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?

조회 수: 9 (최근 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