What does ix=ismembe​r(vars,["s​tate","sou​rce"])| contains(vars,["lat", "lon", "timestamp", "damage", "event"]); do?

조회 수: 3 (최근 30일)
What does the code line
ix=ismember(vars,["state","source"])| contains(vars,["lat", "lon", "timestamp", "damage", "event"]);
As far as I understand, the ix of each row is 1 when "state" and "source" or ["lat", "lon", "timestamp", "damage", "event"] are in the vars-string. Is this correct?
  댓글 수: 1
Stephen23
Stephen23 2022년 1월 13일
Where any element of vars is either:
  • equal to "state"
  • equal to "source"
  • contains "lat"
  • contains "lon"
  • contains "timestamp"
  • etc.
the corresponding element of the output IX will be TRUE, otherwise the element will be FALSE.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2022년 1월 13일
idx1=ismember(vars,["state","source"]) ; % gives logical indexing where state, source are presnt in vars
idx2 = contains(vars,["lat", "lon", "timestamp", "damage", "event"]); % gives logical indices where loat, lon etc are present in vats
ix = idx1 | idx2 ; % gives logical indexing of or of the above indices
  댓글 수: 6
Stephen23
Stephen23 2022년 1월 13일
"Why are there two functions, which do the same thing?"
They don't do the same thing.
Marcel345614
Marcel345614 2022년 1월 13일
Thanks!
What about my second question? (Sorry, it seems that I have edited to late)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by