필터 지우기
필터 지우기

Matching only parts of two cell arrays

조회 수: 1 (최근 30일)
joseph Frank
joseph Frank 2013년 7월 14일
A= {'36450A107';'36467A107';'38067A107'}
B={'36467A'};
How can I find that the 2nd cell in A matches the first 6 characters of B?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 7월 14일
편집: Azzi Abdelmalek 2013년 7월 14일
out=find(cellfun(@(x) strcmp(x(1:6),B),A))

추가 답변 (2개)

Andrei Bobrov
Andrei Bobrov 2013년 7월 14일
find(~cellfun('isempty',regexp(A,B)));

Chandrasekhar
Chandrasekhar 2013년 7월 14일
for i = 1:length(A)
TF = findstr(char(B(1)),char(A(i)))
if(TF == 1)
disp(i)
end
end
  댓글 수: 1
joseph Frank
joseph Frank 2013년 7월 14일
this is not correct I tried it and it gave TF = 1 and 2 . I think you misunderstood the question. I want to find where the 1st 6 characters in A matches B . the 1st row definitely doesn't match nor the 3rd. the only row that matches is the 2nd one.

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

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by