Re: printing an array on one line
Posted by
Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/printing-an-array-on-one-line-tp3705198p3705200.html
> In a macro, I've been calculating statistics based on results
> from 'analyze particles', and I'm sending the results to the
> 'log' window with a 'print' statement.
>
> This is fine when the statistics are defined as variables, but
> for some statistics (histogram bins & percentiles), I need to
> use arrays: the number of bins and percentiles is user-defined.
>
> Is there any way to print an array on *one* log-window line,
> if you don't know in advance the length of the array?
Use string concatenation. Here is an example:
array = newArray(103.3, 84.3, 135.5, 85.0, 175.1);
str = "";
for (i=0; i<array.length; i++)
str = str + array[i] + " ";
print(str);
-wayne