How to get Sum the values of positive even elements from vector x using only one command?

조회 수: 2 (최근 30일)
The question is
Write one Matlab command to get the following from vector x:
  • Sum the values of positive even elements

답변 (1개)

Stephan Ciobanu
Stephan Ciobanu 2021년 1월 14일
% Hi!
% You can try this:
My_sum = sum((x(2:2:end)>0).*x(2:2:end));

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by