Checking ismember (intersect) for lot of arrays

2 views (last 30 days)
Hello, I want to count correlations between 10 derivatives. I have their dates and closing prices. Derivatives arrays have not eaqual date's number. I want to find every array's (containing same dates) indexes that with those indexe's help (derivative1(idx1), derivative2(idx2), derivative3(idx3), derivative4(idx4), ...) I could make a matrix containing[derivative1(idx1),..] and count correlation coeficient. How could I do that. Thank you sincerely!
  1 Comment
Eng. Fredius Magige
Eng. Fredius Magige on 19 Nov 2015
Put down, what you have tried so far. Surely matlab have high ability to solve more many computational challenges, as yours

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Nov 2015
You probably do not want to do that. Instead:
all_dates = unique([dates1(:), dates2(:), dates3(:), ... dates10(:)]);
where dates1 is the date information associated with the first derivative, dates2 is the date information associated with the second derivative, and so on.
After that you can use
proj1 = interp1(dates1, derivative1, all_dates);
proj2 = interp1(dates2, derivative2, all_dates);
and so on, where derivative1 is the pricing information for the first derivative and as before dates1 is the corresponding date information.
The resulting values, proj1, proj2, and so on, are the values of the derivatives all interpolated onto the same set of dates, the union of the set of dates at which there is any information at all. You can then do correlation between the proj1, proj2 and so on, as they will all be the same length.
Note: you may wish to use one of the interp1 options to specifically configure the result of extrapolation; that is, what you want to have returned if you ask to project a value for a time before or after there is corresponding data for one of the derivatives.

Categories

Find more on Price and Analyze Financial Instruments in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!