On May 12, 9:31 pm, David Fanning <n...@dfanning.com> wrote:
> sarah writes:
>> x=make_array(1024)
>> sigma=15
>> mu =15
>> const=1/(sigma*sqrt(2*!pi))
>> for i = 0,1024 do x[i]= array[0,*]
>> f= const*( EXP(-1.0*(x - mu)^2/(2*sigma^2)))
>
>> z = convol(array,array2,/center)
>> z = z*2
>> print,f
>> end
>
>> here is the message I get:% Out of range subscript encountered: X.
>> % Execution halted at: CONV1 29
>> /Users/Dave/Desktop/conv1.pro
>> % $MAIN$
>
>> I don't see why this doesn't work? I am very frustrated
>
> The problem is on this line:
>
> for I = 0,1024 do x[I]= array[0,*]
>
> 0 to 1024 is 1025 numbers. (Count them if you
> don't believe me.) But X is only big enough to
> hold 1024 numbers, so you are, uh, going out
> of its subscript range, as the error message
> suggests.
>
> But this line of code is completely unnecessary.
> Simply typing this is enough:
>
> x = Reform(array[0,*])
>
> 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 for your help! This did indeed solve my problem.
I have developed a new problem in my convolution. It seesm i need to
convolve with a kernel.
I can only convolve two arrays and do not seem to be able to
incorporate the gaussian kernel I need into the convolution.
Is this a three way convolution? I do not know how to do this. I am
trying to convolve 2 datasets with a kernel.
I have tried the code below:
pro conv_nokern
Openr, lun, 'model.dat', /Get_Lun
Point_Lun, lun, 0
ReadF, lun, adim, bdim, num_columns
spec = fltarr(2, 1024)
readf,lun,spec
a = spec(0,*)
b = spec(1,*)
Free_Lun, lun
window,2,xsize=500,ysize=500,retain=2
plot,a,b,yrange=[0,1],xrange=[4265,4200]
openr,lun,'aataunorm.dat',/get_lun
Point_Lun, lun, 1
ReadF, lun, cdim, ddim, num_columns
data = fltarr(2, 1024)
readf,lun,data
c = data(0,*)
d = data(1,*)
window,4,xsize=500,ysize=500,retain=2
plot,c,d,yrange=[0,1],xrange=[4265,4200]
print,data
fconv=convol(b,d,/edge_truncate)
;define convoution function
print,fconv
openw,1,'data.dat'
printf,1,a,fconv
fconv2=fconv/92.4259
window,6,xsize=500,ysize=500,retain=2
plot,a,fconv2,yrange=[0,1],xrange=[4265,4200]
close,1
end
|