comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Plotting functions in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Plotting functions in IDL [message #5504] Wed, 17 January 1996 00:00
M.Reuss is currently offline  M.Reuss
Messages: 4
Registered: January 1996
Junior Member
For plotting, IDL needs a vector of points to plot.
Therefore you evaluate your function at enough points and
then plot this vector.

Suppose the function MYFUNCTION can be evaluated at one point only
in each call and you want to plot it in the range [20,140.], one point
at each integer number being sufficient for you. Then the following should do
the job:

xarr = FINDGEN(121) + 20.
yarr = FLTARR(121)
FOR i = 0,N_ELEMENTS(xarr)-1 DO yarr(i) = MYFUNCTION(xarr(i))

PLOT,xarr,yarr

This will look even more simple if the function code allows to handle
a whole array in one call.

I am afraid I haven't understood what you mean with 'no equations'. You can
code in IDL everything which you can code in FORTRAN, all numerical math
works with IDL (there can be a performance problem, though).
If you mean computer algebra, that's something very different...

Matthias Reuss
Re: Plotting functions in IDL [message #5510 is a reply to message #5504] Wed, 17 January 1996 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
kunstman@pu.informatik.th-darmstadt.de (Thomas Kunstmann) wrote:
> What is the best way of plotting a function in IDL? As far as I know,
> it only handles vectors of discrete data and no equations.

How about the following to plot sin(x) over 0 to 2*pi radians:

xmin = 0.0
xmax = 2.0 * !pi
n = 1000
x = ( findgen( n ) / float( n - 1 ) ) * ( xmax - xmin ) + xmin
plot, x, sin(x)

Use as many points (n) as you like to make a smooth curve.

Cheers,
Liam.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Glitch in TRIGRID using grid spacing
Next Topic: Re: Font Creation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:11:58 PDT 2025

Total time taken to generate the page: 0.00550 seconds