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

Home » Public Forums » archive » Re: A problem using IDL?
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: A problem using IDL? [message #60080 is a reply to message #60079] Fri, 02 May 2008 09:16 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
<chihuyu@sohu.com> wrote in message
news:337cf67f-424c-4bd8-8340-7ec7d0a121a5@l25g2000prd.google groups.com...
> I used idl to write the following:
>
> window,xsize=800,ysize=400
> min=0
> max=100
> n=200
> x=fltarr(n+1)
> for i=0,n do x[i]=min+double(i)*(max-min)/n
> print,x
> y=sin(2*3.141593*x)
> plot,x,y
>
> When n=100 or n=200,the graph is wrong. When n >=300,it's OK.Can
> someone tell me why?


You are aliased. Definitely read up on it if you are not familiar with
aliasing, as it is quite important in spectral analysis. Also read up on
nyquist frequency.

you can write a sinusoid as

y = sin(2*!Pi*f/length*x)

to explicitly have your frequency in there.


Also, check out this code which explicitly shows the
aliasing.

window,xsize=800,ysize=400
min=0
max=100
n=100
x=fltarr(n+1)
for i=0,n do x[i]=min+double(i)*(max-min)/n
;print,x
y=sin(2*3.141593*x)



!P.multi=[0,1,2]

plot,x,y,psym=-4,xr=[0,10]
x1 = x
y1 = y




n=500
x=fltarr(n+1)
for i=0,n do x[i]=min+double(i)*(max-min)/n
;print,x
y=sin(2*3.141593*x)


plot,x,y,psym=-4,xr=[0,10]
oplot,x1,y1,psym=6,thick=4
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: ProductLog function
Next Topic: idl array question

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

Current Time: Fri Oct 10 19:22:23 PDT 2025

Total time taken to generate the page: 1.12019 seconds