BoundsError means you're trying to index out of bounds. I see nothing in 
the backtrace indicating the splice function being involved and I have no 
way of knowing which line in your function is numbered 204 but there's a 
good chance Varraycut[i-1] will try to index at 0 in the first turn of your 
loop when i=1.

Den onsdagen den 30:e juli 2014 kl. 01:14:53 UTC+2 skrev [email protected]:
>
> Hi Julia users,
>
>
> There are a number of things wrong with this script that I am working on, 
> but for the time being, I am trying to resolve a BoundsError() triggered 
> while slicing an array. Code is attached. 
>
> The source of the BoundsError() appears to be this function. 
>
> function spikecounter(Varray)
>>     #spiketimes = Int64[]
>>     Varraycut = splice!(Varray,1:spliceend)
>>     spikecount = 0
>>     for i in Int64[1:len(Varraycut)]
>>         if Varraycut[i] >= 0 && Varraycut[i-1] < 0
>>         #= push!(spiketimes,i)
>>         other option of counting spikes is to append spiketimes to an 
>> array, and then count length of array =#
>>         spikecount += 1
>>     end
>>     end
>>     return spikecount
>> end
>>
>
> Because of other errors in my code, Varray usually contains NaN entries. 
> However, these NaN entries are still appending into my arrays, and I was 
> thinking that if these entries exist, it should still be possible to splice 
> the array. Do these NaN entries preclude Varray from being spliced? 
>
> This is the exact error:
>
> ERROR: BoundsError()
>>  in getindex at array.jl:246
>>  in spikecounter at /Users/xieh/Dropbox/spiking/j2test.jl:204
>>  in moldakarimov at /Users/xieh/Dropbox/spiking/j2test.jl:223
>>  in calcchi at /Users/xieh/Dropbox/spiking/j2test.jl:306
>>  in mcmc at /Users/xieh/Dropbox/spiking/j2test.jl:319
>> while loading /Users/xieh/Dropbox/spiking/j2test.jl, in expression 
>> starting on line 365
>>
>
>
> Thanks,
> Wally  
>
>

Reply via email to