How to do sum of array having decimal value?

조회 수: 3 (최근 30일)
SANDEEP RANA
SANDEEP RANA 2020년 10월 3일
편집: madhan ravi 2020년 10월 3일
For example: I have an array h = [ 0.2 0.54 0.75 1.33]; and I want to sum of the array h from second value to the end. sum(h(2:end);
But this will give an error Subscript indices must either be real positive integers or
logicals
Help me how to address or remove this error.
Thanks

답변 (1개)

madhan ravi
madhan ravi 2020년 10월 3일
편집: madhan ravi 2020년 10월 3일
clear sum
h = [ 0.2 0.54 0.75 1.33 ];
sum(h(2 : end))

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by