How to do sum of array having decimal value?

12 visualizaciones (últimos 30 días)
SANDEEP RANA
SANDEEP RANA el 3 de Oct. de 2020
Editada: madhan ravi el 3 de Oct. de 2020
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

Respuestas (1)

madhan ravi
madhan ravi el 3 de Oct. de 2020
Editada: madhan ravi el 3 de Oct. de 2020
clear sum
h = [ 0.2 0.54 0.75 1.33 ];
sum(h(2 : end))

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by