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!"
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 Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2012년 9월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by