Mistake on programm

Hi,

I have done this programm but I don’t know why I have “infinity” in “number of droplets /cm²” ?
Could you help me to find and resolve it ?

Thank you

Programm :

//Some variables
N=0;
Average_droplet=0;
a=0;

run("Clear Results")

//Scale
run("scale");

//Area fraction and area
getStatistics(area);
print("area [cm²]="+area);
run("area fraction");


//Generate a results table
run("Make Binary");
run("Analyze Particles...", "display clear");
run("Distribution...", "parameter=Area automatic");
selectWindow("Area Distribution");
AreaDistributionContent=getInfo("window.contents");
Plot.getValues(BinArray, CountArray);

//Number of results in "Area" Column
N = nResults;

//Droplet
Average_droplet=N/a

selectWindow("Area Distribution");
run("Close");


if(isOpen("Results")){
  run("Clear Results");
  selectWindow("Results");
  run("Close");
}

//Return values
print("Number of droplet = "+N);
print("Droplet / cm² = "+Average_droplet);

Results

area [cm²]=16.384
Area% =25.8562
Number of droplet = 1582
Droplet / cm² = Infinity

You have:

and

which means you divide by 0 which will yield Infinity as a result.

Maybe you want to divide by area instead of a??

You can usually debug this kind of issues by adding print statements in the macro code to see the value of your variables at a certain point during execution.

1 Like

Hi,

Ok i have found it, I have just written “a” instead of “area”. Sorry

Thank you