| Re: Q:assigning arrays in steps [message #4173 is a reply to message #4162] |
Mon, 08 May 1995 00:00   |
korpela
Messages: 59 Registered: September 1993
|
Member |
|
|
-----BEGIN PGP SIGNED MESSAGE-----
In article <3oikmj$mru@harbinger.cc.monash.edu.au>,
Brett Hennig <bretth@lovelace.maths.monash.edu.au> wrote:
> In Fortran90 you can assign arrays like:
> x(0:10)=y(0:40:4)
> where the last 4 is a step increment.
>
> Can this sort of stuff be done with idl?
You could do it this way.....
x(0:10)=y(indgen(11)*4)
A more generic way would be to write a function that returns a range
x(0:10)=y(range(0,40,4))
in fact, here's one now....
- ------------------------------------------------------------ ------------------
Function range,lo,hi,delta
if (n_params(0) lt 2) or (n_params(0) gt 3) then begin
print,'RANGE-- Incorrect number of parameters'
return,-9999.0
endif
if (n_params(0) eq 2) then delta=1.0
number=long((float(hi)-float(lo))/float(delta))+1
outrange=float(lo)+findgen(number)*float(delta)
return,outrange
end
- ------------------------------------------------------------ ------------------
-----BEGIN PGP SIGNATURE-----
Version: 2.6
iQCVAwUBL65zkOBZ/OT/DJLdAQHwtQP/RiHqWcmZVhz20xiNdi82Y80KZyww PhNP
Vg9Nj3Vqv9sBSS+oL5xdOaESLsgkgnhldIBEGlkC5q5eTuSXz7ZaRWRLngL4 +q6n
dILsQJ+Aj63QtA8MXT/XFfjoQ4HzxuMP/1rD7S50q57tjdfL3538s3/A8Sa4 c591
S/0UE6nOcGY=
=9iTd
-----END PGP SIGNATURE-----
--
Eric Korpela | A day without meetings is like
korpela@ssl.berkeley.edu | work.
<a href=" http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpe la/w">Click here for more info.</a>
|
|
|
|