Comparing cell with criteria

1 view (last 30 days)
Cside
Cside on 25 Feb 2020
Commented: Cside on 25 Feb 2020
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 Comments
Cside
Cside on 25 Feb 2020
I did, but I'm not certain how to include Q1 into the code. still learning, am a beginner~

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 25 Feb 2020
Edited: Stephen23 on 25 Feb 2020
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 Comment
Cside
Cside on 25 Feb 2020
it was helpful, thank you :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by