Problem aligning data

3 次查看(过去 30 天)
Jens Schaldemose
Jens Schaldemose 2012-5-7
I'm currently doing my bachelor thesis and I'm having a problem with a code that does not work for me.. I have 248 observations of stock returns and I have 252 index returns. I need to remove the dates and returns from the index where trading days are missing so I will obtain 248 index returns. I have used the following codes, but it does not remove my data like i want it to do:
ds=datesstock; ps1=returnstock; dm=datesindex; m = length(dm); n = length(ds);
if (m > n) ps = zeros(m,1); c = 1; for i=1:m j = find (dm(i)== ds); if (isempty(j)) ps(i) = NaN; else ps(i) = ps1(c); c = c+1; end end else ps = ps1; end
  1 个评论
Jan
Jan 2012-5-7
1. Please format your code as explained in the "Markup help" link.
2. "It does not remove my data like I wanted" is not helpful to find out, what you want and what you get. We cannot run the posted code and guessing the difference between your intention and the results is impossible.
3. While terms like "observation of stock returns" is surely meaningful for you, it is not for scientist of other fields. For Matlab the meaning of the variables does not matter at all, so it would be more clear if you write: I have a [1 x N] vector of type DOUBLE.
Please edit your original question to add the clarifications. Do neither post them as comment, answer or new thread, because this would be less helpful for the readers of your question. Thanks.

请先登录,再进行评论。

回答(1 个)

bym
bym 2012-5-7
doc intersect()

类别

Help CenterFile Exchange 中查找有关 Holidays / Seasons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by