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

Home » Public Forums » archive » How to give values as a range in array?
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
How to give values as a range in array? [message #93376] Tue, 28 June 2016 07:02 Go to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
I need to fill an array with values say,0 to 100.Is there keyword to do that(without using any loops)?
Re: How to give values as a range in array? [message #93377 is a reply to message #93376] Tue, 28 June 2016 07:23 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdag 28 juni 2016 kl. 16:02:54 UTC+2 skrev Meegle_Jade:
> I need to fill an array with values say,0 to 100.Is there keyword to do that(without using any loops)?

array = indgen(101)
Re: How to give values as a range in array? [message #93378 is a reply to message #93376] Tue, 28 June 2016 07:30 Go to previous messageGo to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
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?
Re: How to give values as a range in array? [message #93379 is a reply to message #93378] Tue, 28 June 2016 07:45 Go to previous messageGo to next message
Helder Marchetto is currently offline  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 #93380 is a reply to message #93376] Tue, 28 June 2016 07:50 Go to previous messageGo to next message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
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?
Re: How to give values as a range in array? [message #93383 is a reply to message #93380] Tue, 28 June 2016 09:41 Go to previous messageGo to next message
Helder Marchetto is currently offline  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
Re: How to give values as a range in array? [message #93385 is a reply to message #93376] Tue, 28 June 2016 20:16 Go to previous message
Sonu Tabitha is currently offline  Sonu Tabitha
Messages: 29
Registered: April 2016
Junior Member
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)?

Thanks a lot!! It solved the issue... :)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Bug in legend() for horizontal orientations
Next Topic: How to overplot in log scale?

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

Current Time: Wed Oct 08 11:28:45 PDT 2025

Total time taken to generate the page: 0.00553 seconds