Re: How to draw function plot in ImageJ?

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/How-to-draw-function-plot-in-ImageJ-tp3703127p3703128.html

> Hi,
>   if I have a function, for example,
>   f(t) = 6*t*t*t + 4*t*t + 3*t + 1,
>   t is in [0.0, 1.0]
>   May I use ImageJ to draw the function plot?
>   Thanks!

You can plot a function using a macro, for example,

   n = 100;
   xpoints = newArray(n);
   ypoints = newArray(n);
   xmax = 1;
   xinc = xmax/n;
   x = 0;
   for (i=0; i<n; i++) {
       xpoints[i] = x;
       ypoints[i] = f(x);
       x += xinc;
   }
   Plot.create("Function", "t", "f(t)", xpoints, ypoints);
   exit;

   function f(t) {
       return 6*t*t*t + 4*t*t + 3*t + 1;
   }

-wayne