Chris_30 0 Newbie Poster

I have a real time signal (which the result of a function of mine over time). I want to calculate when the signal overcome a threshold when in ascending order and when it goes down the threshold in descending order. My matlab function to do so is the following:

X = find(diff(S> 0.25)==1);
Y = find(diff(S< 0.25)==1); 

THe result of diff is 1 is the value of S increasing -1 is the value of S is decreasing and 0 when it remains the same. I want to perform something likethat in c#. Any idea? Diff stands for differential of a function is a default method from matlab toolbox. S is a vector of 1x1000 with (S>0.25) I take a vector of 1x1000 logical values either 1 or 0 if the signal is higher than the threshold or not. With the diff, I get a vector of -1, 0, 1, 1 for the case that the current position in (S>0.25) vector is bigger than the previous state(from 0->1), 0 when it is the same and -1 when the new state is lower than the previous(from 1->0). What I do finally to keep only the position of the ones in the final vector. How can I do so in c# code real time.