Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Can I join with 1 variable and 1 value as "keyword"?

조회 수: 2 (최근 30일)
Mario Diaco
Mario Diaco 2020년 5월 29일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi!
Can I match by dates and by country names?
I've matched by dates, but the code capture all countries.
Thanks
  댓글 수: 1
Adam Danz
Adam Danz 2020년 5월 29일
Images of text are always really hard to work with. Copying the text directly is much better (just FYI for future posts).

답변 (1개)

Adam Danz
Adam Danz 2020년 5월 29일
isMatch = dateMatches && ismember(T.Country, {'Austria','Belgium'});
Replace dateMatches with your date-matching code that produces a logical vector of date matches.
Replace T with your table name and list the countries you'd like to match.
isMatch is a logical vector of row-matches.
  댓글 수: 2
Mario Diaco
Mario Diaco 2020년 5월 30일
Thanks for the suggestions. How I can create a logical vector of date to match?
dateMatches =
60×1 datetime array
31-Jan-2015
28-Feb-2015
31-Mar-2015
30-Apr-2015
31-May-2015
30-Jun-2015
31-Jul-2015
31-Aug-2015
30-Sep-2015
31-Oct-2015
30-Nov-2015
31-Dec-2015...
Adam Danz
Adam Danz 2020년 5월 31일
편집: Adam Danz 2020년 6월 2일
I thought you had alread done that. In your question, "I've matched by dates, but the code capture all countries.".
If you have a list of dates D and a 2nd list of dates D2, to find the dates in D that are listed in D2,
ismember(dateshift(D,'start','day'), dateshift(D2,'start','day'))
If you're trying to find all dates in D that are within range of date1 to date2,
D >= date1 & D <= date2;

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by