Re: Sum of all elements in an array
Posted by
Gabriel Landini on
Dec 29, 2014; 12:22pm
URL: http://imagej.273.s1.nabble.com/Sum-of-all-elements-in-an-array-tp5011059p5011060.html
On Monday 29 Dec 2014 11:58:23 you wrote:
> If I create an array :
> A=newArray(1,2,3);
> I would like to make operations on the 3 elements for instance summing or
> multiplications (1+2+3 or 1*2*3 etc.)
I would not be reasonable to expect every possible operation to have its own
function. Just use the macro language:
total=0;
A=newArray(1,2,3);
for (i=0;i<lengthOf(A);i++){
total=total+A[i];
}
print (total);
or use
total=1; and total=total*A[i];
for the multiplication of the array entries.
Cheers
Gabriel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html