intersection of two tables question

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

 採用された回答

Matt Fig
Matt Fig 2012 年 9 月 27 日

0 投票

A(all(~cellfun('isempty',B),2),:)

3 件のコメント

Matt Fig
Matt Fig 2012 年 9 月 27 日
編集済み: Matt Fig 2012 年 9 月 27 日
Leon comments:
"Great! Thank you very much. Can you tell me as well how I get the exact inverse, I mean all entries of A where B is empty?
Regards!"
Matt Fig
Matt Fig 2012 年 9 月 27 日
Yes, just take off the ~.
A(all(cellfun('isempty',B),2),:)
Léon
Léon 2012 年 9 月 27 日
Thank you very much indeed!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

質問済み:

2012 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by