
Originally Posted by
rancediddy
Hello
I'd appreciate any help or recommendations I can get for my problem.
The basic problem:
I have a large column of data and I would like to evaluate when data in the column becomes less than predetermined value (this I can do). However the second part of this requires the data to be less than the predetermined value for a specified period of time (or number of cells) or it does not get considered.
Make sense?
Does anyone have suggestions?
Thanks in advance!
There is more than one way to skin this cat but this is one way:
Code:
--> data=rand(20,1)
data =
0.5322
0.2064
0.7200
0.0361
0.1283
0.3153
0.1913
0.9270
0.4376
0.5417
0.6870
0.5197
0.4237
0.2228
0.7730
0.5879
0.9323
0.7247
0.6626
0.5490
--> bdata=data>0.25
bdata =
1
0
1
0
0
1
0
1
1
1
1
1
1
0
1
1
1
1
1
1
--> delta=bdata(1:length(bdata)-1)- bdata(2:length(bdata))
delta =
1
-1
1
0
-1
1
-1
0
0
0
0
0
1
-1
0
0
0
0
0
--> dd=(delta==0)
dd =
0
0
0
1
0
0
0
1
1
1
1
1
0
0
1
1
1
1
1
--> ii=[1:length(dd)]';
--> zz=nonzeros(dd.*ii)
zz =
4
8
9
10
11
12
15
16
17
18
19
The values in zz are indices into the data matrix of elements that are less than the threshold and also the next element is less than the threshold.
RonL