From: Jean-Philip Dumont on
Hi,

I have those two matrices :

M = [0,0,0,0,0,0,-1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,-1,-1,-1,0,0,0,0,0,0,1,0,0,-1,0,0,1,-1,1,-1,0,0,1,-1,0,0,0,0,0,0,1,-1]'

Index = [32,86,137,145,209,262,484,638,660,765,823,970,984,1140,1212,1291,1375,1383,1458,1544,1595,1668,1738,1852,1886,2034,2070,2232,2364,2418,2536,2616,2651,2733,2767,2825,2879,3028,3120,3196,3369,3399,3483,3591,3724,3841,4099,4137,4158,4260,4447,4503,4512,4525,4530,4571,4583,4775,5053]'

Those two matrices are of the same length (59x1) and here what information they are providing :
Matrice M : When the value is 0, we are in a downward trend (concerning an exchange rate). When the value is 1, we are in an upward trend and when the value is -1, we are in a downward trend.
Index : It gives the index of my exchange rate time serie corresponding to the value of matrice M.

Here what I would like to do:

I would like to use the Matrice "M" where all the trends are identified and the matrice "Index" to physically separate my data into series with trend. For example, I have the value 0 from line 1 to line 6 into the matrice M which means to me that I consider a stable market from line 1 to line 262 of the exchange rate time serie (262 is the value in line 6 of the Index matrice). Then I have -1 at line 7 of the matrice M. I would then like to create a serie that is formed with the data of my exchange rate serie from line 262+1 to 484 (484 is the value in line 7 of the Index matrice). After, I have 1 from line 8 to 15 of my matrice M. I would then like to create a separate matrice formed of the exchange rates from line 484+1 to 1140 (1140 is the value in line 14 of the Index matrice). I would like to do this for all my matrice M and identify and separate all the upward, downward and stable
trend of the exchange rate.

Can someone help me on that? Is there an automatic way of doing this instead of doing it manually? I was thinking of using "eval" to create different names for all my time series.

Thank you very much!

JP