Hi all, I have two vectors, one is "Beg_Data" which has 19 values and I have another reference vector "Beg_In_Ex" which contains 1239 values (Data attached). I am computing a new vector "End_Cycle" same size (19 values) that of "Beg_Data" vector based on the nearest neighbour search. I would like to achieve the results of "End_Cycle" values lower than that of corresponding values that of "Beg_Data". However, using the method that I have attempted I found some values are always higher than that of the "Beg_Data" values. As you can see I want the difference to be always positive (End_Cycle<Beg_Data). Any help in this regard is highly appreciated.
End_Cycle = dsearchn(Beg_In_Ex',Beg_Data);
End_Cycle = Beg_In_Ex(End_Cycle)';
Start_Stop = [End_Cycle Beg_Data]
Start_Stop =
1.0e+06 *
0.0746 0.0761
0.2064 0.2047
0.2327 0.2346
0.4144 0.4130
0.5276 0.5263
0.6324 0.6329
0.8096 0.8088
0.9534 0.9518
0.9722 0.9702
0.9777 0.9760
Difference = Start_Stop(:,2)-Start_Stop(:,1)
Difference =
1.0e+03 *
1.4242
-1.6832
1.9540
-1.3347
-1.3141
0.4402
-0.7642
-1.6077
-2.0212
-1.6784