Indexing of a Float64 is actually a bit inconsistent. It works for a single 
integer, but not for Ranges.

*julia> **a=4.5*

*4.5*

*julia> **a[1]*

*4.5*

*julia> **a[1:-1:1]*

*ERROR: `getindex` has no method matching getindex(::Float64, 
::StepRange{Int64,Int64})*

*julia> **a[1:1]*

*ERROR: `getindex` has no method matching getindex(::Float64, 
::UnitRange{Int64})*




On Monday, April 6, 2015 at 10:19:30 AM UTC-6, Jim Christoff wrote:
>
> Thank you very much for that clear description. That was the problem and 
> it is producing the expected results. 
>
> On Monday, April 6, 2015 at 10:53:40 AM UTC-4, ggggg wrote:
>>
>> I suspect you want 
>>
>>     ## generate next filter order
>>     if i==1
>>       a[i] =  g  
>>     else
>>       a[i-1:-1:1] =   a[i-1:-1:1]-g*a[i-1:-1:1]  # **** this is my 
>> problem area*****
>>     end
>>
>> a is first assigned as a Vector{Float64} of length p.  Then you did a=g 
>> which assigns a as a Float64 (this is bad for performance as well, since 
>> it's not type stable). Then you try to a[1] when i=2, but in Julia (unlike 
>> MATLAB, and I assume octave) that is not a valid access.  You want to make 
>> sure a stays as a Vector{Float64} the whole time, and while you can change 
>> the length if you want, you will probalby be better off if you keep it the 
>> same length as well.
>>
>

Reply via email to