Question: sum of element of a given vector

Dear all

I have data and a vector d. 
I would like to sum the elements of the vector d corresponding to the index  of the element data <=0.01 

Step 1: we select the index of data that corresponds to data<=0.01

step 2: we select the consecutive index corresponding to data<=0.01

Step 3 : we sum the element of d corresponding to the previous index

step 4: update d=d/number(index) ;

Please see my attached code. It's done by hand how can reformulate the code.

 

 

code_vector.mw

many thanks

 

Please Wait...