Hi,
I have a set of 5 cells (a row vector), each cell containing a number from -1 to +1. Reading through the values from first to last, I want to count how many times it changes sign (i.e. from positive to negative or vice versa). Zeros are present but need to be ignored (skipped). For example:
-1 0 1 1 -1 would yield two sign changes (initial value is negative and it switches to positive and then back to negative)
0 0 1 1 0 would yield zero sign changes (first non-zero value is positive and it remains so)
-1 0 0 1 0 would yield one sign change
Obviously I could do this by hand for a small number of vectors, but I need to repeat this calculation across thousands of unique 5 number sets. Although my example above only uses values of -1, 0, +1, I may also need to generalize this such that the numbers may include several different negative and positive values (again, only sign changes are of interest however).
Any suggestions would be much appreciated. I am working in xl2010.
Thanks,
Howard
I have a set of 5 cells (a row vector), each cell containing a number from -1 to +1. Reading through the values from first to last, I want to count how many times it changes sign (i.e. from positive to negative or vice versa). Zeros are present but need to be ignored (skipped). For example:
-1 0 1 1 -1 would yield two sign changes (initial value is negative and it switches to positive and then back to negative)
0 0 1 1 0 would yield zero sign changes (first non-zero value is positive and it remains so)
-1 0 0 1 0 would yield one sign change
Obviously I could do this by hand for a small number of vectors, but I need to repeat this calculation across thousands of unique 5 number sets. Although my example above only uses values of -1, 0, +1, I may also need to generalize this such that the numbers may include several different negative and positive values (again, only sign changes are of interest however).
Any suggestions would be much appreciated. I am working in xl2010.
Thanks,
Howard