필터 지우기
필터 지우기

Comparing cell with criteria

조회 수: 1 (최근 30일)
Cside
Cside 2020년 2월 25일
댓글: Cside 2020년 2월 25일
Hello! I have cell matrix "Spfcfef" (120x2) as attached and would like to produce 3 outputs.
1) numbers 1-9, that did not appear in either columns, by rows. The result should be a 120 x 1 cell.
2) numbers that appeared in column 1, but not in column 2
Is there a function in matlab that I may use to compare between columns/code with? Many thanks! :)
  댓글 수: 2
Stephen23
Stephen23 2020년 2월 25일
편집: Stephen23 2020년 2월 25일
Earlier very similar questions, with answers that use ismember:
"Is there a function in matlab that I may use to compare between columns/code with?"
Have you considered using ismember ? At the bottom of every function's documentation page is a section entitled "See Also", which contains a list of related functions, you can find several functions that would help do what you want.
Cside
Cside 2020년 2월 25일
I did, but I'm not certain how to include Q1 into the code. still learning, am a beginner~

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

채택된 답변

Stephen23
Stephen23 2020년 2월 25일
편집: Stephen23 2020년 2월 25일
out1 = cellfun(@(l,r) setdiff(1:9,[l,r]), Spfcfef(:,1), Spfcfef(:,2), 'Uni',0);
out2 = cellfun(@(l,r) setdiff(l,r), Spfcfef(:,1), Spfcfef(:,2), 'Uni',0);
  댓글 수: 1
Cside
Cside 2020년 2월 25일
it was helpful, thank you :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by