[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: lookback function? or instlookback?

**From**: |
Francesco Potorti` |

**Subject**: |
Re: lookback function? or instlookback? |

**Date**: |
Thu, 01 Dec 2005 10:19:47 +0100 |

>*-Take two specific vectors of data, say I and J*
>*-Start two counters at the first element. One increments by one every row*
>*(until reset) and the other increments by 1 when either*
>* --there is a non-zero difference between the current non-zero*
>*value of I and the most recent previous non-zero value of I*
>* or*
>* --the same is true for J*
>*The other challenge is that both I and J change their non-zero values at*
>*the same time, but because only I or J is non-zero in a given row, I also*
>*have to figure out how to tell the counters to reset & increment for the*
>*first of those two changes but not for the second.*
It seems to me that the two statements
- both I and J change their non-zero values at the same time
- only I or J is non-zero in a given row
are contradictory, so I don't understand what you want to do.
Anyway, if I have understood anything, this kind of things can be done
using combinations of the functions cumsum, diff and find, possibly with
the help of prepad and postpad.
--
Francesco PotortÃ¬ (ricercatore) Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR Fax: +39 050 313 8091
via G. Moruzzi 1, I-56124 Pisa Email: address@hidden
Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------

**Re: lookback function? or instlookback?**,
*Francesco Potorti`* **<=**