Re: Beginner: Oplot line t^(-5/3) [message #82033 is a reply to message #82032] |
Mon, 12 November 2012 08:35  |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Monday, November 12, 2012 5:20:31 PM UTC+1, 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
>
>
>
> I have used 9999 as 1E+5 was apparently too large, or something..
>
>
>
> Any help would be much appreciated!!
>
>
>
> Charlie
I would do it like this (using double precision):
n=1d-4
t=dindgen(9999)+1d ; starting from t=0 makes no sense, start from 1
line=n*t^(-5d /3d)
window, xsize=600, ysize=400 ; create a window for display
plot, t, line, /ylog ; plot in y-log coordinates
Avoid loops, unless strictly necessary.
Cheers,
Helder
|
|
|