I have a cell array of up to hundreds of elements say A = cell(1,100). Each cell has a variety of three-column vectors (all 3-columns but could vary in number of rows): A{1} = [1 2 3; 4 5 6; 7 8 9]; etc.
Is there a way to use the built-in functions to see if the vector [1 2 3] exist in A?

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2017년 6월 15일

0 개 추천

A{1}= [1 2 3; 4 5 6; 7 8 9];
A{2}= [11 2 3; 4 5 6];
A{3}= [1 12 3];
IsInA=any(cellfun(@(x) ismember([1 2 3], x,'rows'),A))

댓글 수: 2

Zhangxi Feng
Zhangxi Feng 2017년 6월 15일
Thanks! I have used similar clauses before but never really understood how it works. What is the meaning of @(x)?
Fangjun Jiang
Fangjun Jiang 2017년 6월 16일
doc('anonymous functions')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2017년 6월 15일

댓글:

2017년 6월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by