[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lsim and butter for octave
From: |
Mario Storti |
Subject: |
Re: lsim and butter for octave |
Date: |
Thu, 24 Sep 1998 18:45:25 +0200 |
>>>>> On Thu, 24 Sep 98 18:12:32 ,
>>>>> "Erich Schneider" <address@hidden> said:
> ................. < lines snipped here > ..............
> BTW, when trying to port these files there was a problem with the
> indexing of vectors. If I define a vector d = [3 4 5 6] I get this
> answer for d(d>1):
>> d=[3 4 5 6];
>> d(d>1)
> ans =
> 3 3 3 3
> The indexing mechanism seems to be buggy when the indexing vector only
> consists of ones. As soon as the vector contains a 0 it works as
> expected. If I want to get d(d>4) I get the right answer:
> oct:115>d(d>4)
> ans =
> 5 6
> A workaround is to use e.g. d(find(d>1)). However, since a lot of
> m-files use this indexing technique this is pretty annoying bug.
> Regards,
> Erich Schneider
You have to set `prefer_zero_one_indexing' to 1
> octave.bin:44> d=[3 4 5 6]
> d =
>
> 3 4 5 6
>
> octave.bin:45> d(d>1)
> ans =
>
> 3 3 3 3
>
> octave.bin:46> prefer_zero_one_indexing=1
> prefer_zero_one_indexing = 1
> octave.bin:47> d(d>1)
> ans =
>
> 3 4 5 6
>
>From the Octave's manual:
> This special zero-one form of indexing leads to a conflict with the
> standard indexing operation. For example, should the following
> statements
>
> a = [1, 2; 3, 4];
> a ([1, 1], :)
>
> return the original matrix, or the matrix formed by selecting the first
> row twice? Although this conflict is not likely to arise very often in
> practice, you may select the behavior you prefer by setting the built-in
> variable `prefer_zero_one_indexing'.
>
> - Built-in Variable: prefer_zero_one_indexing
> If the value of `prefer_zero_one_indexing' is nonzero, Octave will
> perform zero-one style indexing when there is a conflict with the
> normal indexing rules. *Note Index Expressions::. For example,
> given a matrix
>
> a = [1, 2, 3, 4]
>
> with `prefer_zero_one_indexing' is set to nonzero, the expression
>
> a ([1, 1, 1, 1])
>
> results in the matrix `[ 1, 2, 3, 4 ]'. If the value of
> `prefer_zero_one_indexing' set to 0, the result would be the
> matrix `[ 1, 1, 1, 1 ]'.
>
> In the first case, Octave is selecting each element corresponding
> to a `1' in the index vector. In the second, Octave is selecting
> the first element multiple times.
>
> The default value for `prefer_zero_one_indexing' is 0.
>
Regards,
Mario