How to draw function plot in ImageJ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to draw function plot in ImageJ?

panovr
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!

Yili Zhao

Reply | Threaded
Open this post in threaded view
|

Re: How to draw function plot in ImageJ?

Wayne Rasband
> 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