How to catch the index of immediate greater number in other matrix?
Consider example
a=rand(5,1)
b=rand(5,1);
bs=sum(b);
B=b./bs;
cB=cumsum(B)
%OUTPUT
a =
0.7803
0.3897
0.2417
0.4039
0.0965
cB =
0.0495
0.4030
0.7617
0.9776
1.0000
now i want the position of the number in cB which is immediately greater
than the number in a. that is to say i want 5 positions corresponding to
each number in a. So my output should be
P= [4;2;2;3;2]
Please help.
No comments:
Post a Comment