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

Home » Public Forums » archive » Re: very simple Index question~~~help~~~
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: very simple Index question~~~help~~~ [message #62531] Tue, 16 September 2008 09:35
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"xiao" <littledddna@gmail.com> wrote in message
news:1e78d923-49cd-4480-978d-d742c71aa7ca@m45g2000hsb.google groups.com...
> I have a very simple question , I have an 178*300 array, I want to
> read it line by line like this :
>
> print,diff(53399)
> print,diff(178*299+177) ;178*299+177=53399


IDL> print,178*299+177

-12137
Re: very simple Index question~~~help~~~ [message #62532 is a reply to message #62531] Tue, 16 September 2008 08:54 Go to previous message
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
On Sep 16, 3:22 am, Carsten Lechte <c...@toppoint.de> wrote:
> xiao wrote:
>> I have a very simple question , I have an 178*300 array, I want to
>> read it line by line like this :
>
>> print,diff(53399)
>
> This works, and this
>
>> print,diff(178*299+177) ;178*299+177=53399
>
> does not? Try
>
> PRINT, 178*299+177
>
> and you will probably see a negative number.
>
> Visithttp://www.dfanning.com/code_tips/mostcommon.htmland read
> "Problems Caused by Short Integers". Swearing is optional;-)
>
> chl

hmm...very smart :)
Re: very simple Index question~~~help~~~ [message #62541 is a reply to message #62532] Tue, 16 September 2008 01:22 Go to previous message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
xiao wrote:
> I have a very simple question , I have an 178*300 array, I want to
> read it line by line like this :
>
> print,diff(53399)

This works, and this

> print,diff(178*299+177) ;178*299+177=53399

does not? Try

PRINT, 178*299+177

and you will probably see a negative number.

Visit http://www.dfanning.com/code_tips/mostcommon.html and read
"Problems Caused by Short Integers". Swearing is optional;-)


chl
Re: very simple Index question~~~help~~~ [message #62542 is a reply to message #62541] Tue, 16 September 2008 00:09 Go to previous message
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
On Sep 15, 10:59 pm, David Fanning <n...@dfanning.com> wrote:
> xiao writes:
>> I think it is over floating.......How can I solve this?
>
> Try making your loop counter a LONG integer:
>
>    FOR j=0L, n DO ...
>
> Or, even better, make *all* your integers LONG integers:
>
>    COMPILE_OPT defint32
>
> Here is an article you probably ought to read:
>
>   http://www.dfanning.com/code_tips/mostcommon.html
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Thank you very much, David :)
Re: very simple Index question~~~help~~~ [message #62543 is a reply to message #62542] Mon, 15 September 2008 20:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xiao writes:

> I think it is over floating.......How can I solve this?

Try making your loop counter a LONG integer:

FOR j=0L, n DO ...

Or, even better, make *all* your integers LONG integers:

COMPILE_OPT defint32

Here is an article you probably ought to read:

http://www.dfanning.com/code_tips/mostcommon.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: very simple Index question~~~help~~~ [message #62544 is a reply to message #62543] Mon, 15 September 2008 20:56 Go to previous message
xiao zhang is currently offline  xiao zhang
Messages: 81
Registered: June 2008
Member
On Sep 15, 10:49 pm, David Fanning <n...@dfanning.com> wrote:
> xiao writes:
>> I have a very simple question , I have an 178*300 array, I want to
>> read it line by line like this :
>
>> print,diff(53399)
>> print,diff(178*299+177) ;178*299+177=53399
>
>> for i=0,177 do begin
>> diff2(i)= diff(178*299+i)
>> endfor
>
>> Why it always remind me that it out of range in the second print
>> statement. I mean 178*299+177 s exactly equal to 53399.
>
> IDL arrays are indexed starting from 0 and not 1. If you
> get to 53399, you have exceeded the bounds of the array,
> which go from index 0 to 53398.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

I think it is over floating.......How can I solve this?
TNX
Re: very simple Index question~~~help~~~ [message #62545 is a reply to message #62544] Mon, 15 September 2008 20:49 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
xiao writes:

> I have a very simple question , I have an 178*300 array, I want to
> read it line by line like this :
>
> print,diff(53399)
> print,diff(178*299+177) ;178*299+177=53399
>
> for i=0,177 do begin
> diff2(i)= diff(178*299+i)
> endfor
>
>
> Why it always remind me that it out of range in the second print
> statement. I mean 178*299+177 s exactly equal to 53399.

IDL arrays are indexed starting from 0 and not 1. If you
get to 53399, you have exceeded the bounds of the array,
which go from index 0 to 53398.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL is giving me a syntax error out of nowhere
Next Topic: Exporting iPlot graphics to EPS files in vector format?

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

Current Time: Wed Oct 08 19:39:16 PDT 2025

Total time taken to generate the page: 0.00665 seconds