Problem aligning data
조회 수: 3 (최근 30일)
이전 댓글 표시
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
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!