How to compare two date vectors?
조회 수: 3 (최근 30일)
이전 댓글 표시
Dear all, I have two date vectors, which I converted with datenum. They had have the string format dd.mm.yyyy. The one vector control is a 3288*1 vector and the other one t is 2753*1 vector. So, I want to check wich dates of control are in t! And if one date of control is t, then matlab should make a 1 in count! Thus I can identify the matches! I tried it with the following order:
count = zeros(length(control), 1);
for i = 1:length(control)
if control(i,1) == t(1:end);
count(i,1) = 1;
end
end
But it is not working. After the loop there still only zeros in count! What is wrong or what do I have to add???
Thank you in advance!
댓글 수: 0
채택된 답변
the cyclist
2013년 3월 30일
I think you will find the ismember() command to be what you need. If I understand correctly, I think you want:
count = ismember(control,t)
but certainly test it for yourself.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!