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

Home » Public Forums » archive » Re: Beginner: Oplot line t^(-5/3)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Beginner: Oplot line t^(-5/3) [message #82028] Mon, 12 November 2012 12:25 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Monday, November 12, 2012 11:20:31 AM UTC-5, Charlie Paul D'auria wrote:
> Hi there!
>
>
>
> Please bear in mind that I am a complete IDL beginner so excuse any foolishness!
>
>
>
> I have managed to plot an XY graph with data plots.
>
>
>
> My problem lies with my next stage: I need to generate a line of gradient t^(-5/3) (then use oplot over my data).
>
>
>
> I get the error 'Attempt to subscript T with I is out of range.' and when I type print,line I only get one value for my line...
>
>
>
> Here is some code I was provided with as a guide, which I have modified slightly:
>
>
>
> line=dblarr(9999)
>
> n=1E-4
>
> t=dblarr(9999)
>
>
>
> for i=0,9999 do begin
>
> t(i)=i
>
> line=n*t(i)^(-5./3.)
>
> endfor
>

The other posters showed you how to vectorize your problem. I'll point out the problem with your code.

A FOR loop from 0 through 9999 contains 10000 elements, because 0 is included in the count. Therefore you should dimension your variables with 10000 elements.

The IDL Way is that a variable declared like this,
T = dblarr(N)
Is stepped through like this,
FOR i = 0L, n_elements(T)-1 do begin ...
Note the "-1"

Craig
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: correlation of single pixels
Next Topic: envi_get_data

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

Current Time: Wed Oct 08 17:14:16 PDT 2025

Total time taken to generate the page: 0.00424 seconds