intersection of two tables question

1 view (last 30 days)
Léon
Léon on 27 Sep 2012
Hello,
I have 2 cell arrays of the following form:
A = {1,2,3;'a','b','c';'e','f','g'};
B = {'x','y';[],[];'z','v'};
and I want to create a third cell array with the content of A, but with only those rows that are not empty in B. What is the most efficient way to do that?
The result should be:
C = {1,2,3;'e','f','g'};
Help is greatly appreciated

Accepted Answer

Matt Fig
Matt Fig on 27 Sep 2012
A(all(~cellfun('isempty',B),2),:)
  3 Comments
Matt Fig
Matt Fig on 27 Sep 2012
Yes, just take off the ~.
A(all(cellfun('isempty',B),2),:)
Léon
Léon on 27 Sep 2012
Thank you very much indeed!

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!