How to find common value from cell

Need help in finding common values in cell. For example i have a cell like cc={[1 2 3],[1 2 4 5];[1 2 8 7 9 5],[1 3 8 7 2]}; then i want output as [1 2] as it is common in all cell matrix.

 Accepted Answer

cc = {[1 2 3],[1 2 4 5];[1 2 8 7 9 5],[1 3 8 7 2]};
result = cc{1};
for jj = 2:numel(cc)
result = intersect(result,cc{jj});
end
disp(result);
1 2

2 Comments

( @Tukaram Zore Answer moved here: )
Thank You very much.
@Tukaram Zore You're welcome!

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Asked:

on 17 Jun 2022

Commented:

on 17 Jun 2022

Community Treasure Hunt

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

Start Hunting!