|
|
|
Re: How to give values as a range in array? [message #93379 is a reply to message #93378] |
Tue, 28 June 2016 07:45   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, June 28, 2016 at 3:30:42 PM UTC+1, Meegle_Jade wrote:
> On Tuesday, June 28, 2016 at 7:32:54 PM UTC+5:30, Meegle_Jade wrote:
>> I need to fill an array with values say,0 to 100.Is there keyword to do that(without using any loops)?
>
> What if the values are from 100 to 700 or so? How can I do it?
from IDL 8.3 onwards:
findgen(600, start=100, increment=1)
Increment keyword is not needed... I just put it in in case you ask for it...
Otherwise
findgen(600)+100
cheers
|
|
|
|
Re: How to give values as a range in array? [message #93383 is a reply to message #93380] |
Tue, 28 June 2016 09:41   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Tuesday, June 28, 2016 at 3:50:53 PM UTC+1, Meegle_Jade wrote:
> On Tuesday, June 28, 2016 at 7:32:54 PM UTC+5:30, Meegle_Jade wrote:
>> I need to fill an array with values say,0 to 100.Is there keyword to do that(without using any loops)?
>
> Infact, I need to plot flux values for frequencies ranging from 100GHZ to say 2000GHz . The frequencies need not be integers. I have IDL version 7. What to do?
I would expect that the frequency corresponding to each flux is in some data file and that you should use as an array. However, if you have to generate the frequencies, the exact command depends on what you want to achieve.
I would drop the "giga" and mention that on the axis so that you're plotting values between 100 and 2000 and the axis is something like "Frequency (GHz)".
How many values do you have and how are they spaced?
Lets say you have 201 values, then you need an array with 201 elements:
freq = findgen(201)
This is now an array like this: 0, 1, 2, ..., 199, 200
If these have to be spaced equally between 2000 and 100, then you have a delta of 1900/200=9.5. So you need to multiply the array freq by 9.5 and add 100:
freq = freq * 9.5 + 100
and you get an array like this: 100, 109.5, 119, ..., 1990.5, 2000.
I hope that makes sense.
Cheers
|
|
|
|