필터 지우기
필터 지우기

How can I select a cell containing a specific text from a nx1 cell array and store it in a variable?

조회 수: 8 (최근 30일)
How can I select a cell containing a specific text from a nx1 cell array and store it in a variable?
a =
nx1 cell array
{'data1 = 231'}
{'line = 5457'}
{'data2 = a'}
{'sample = 889'}
{'ddf = 22'}
...
I want to make this result.
line =
1x1 cell
{'line = 5457'}
sample =
1x1 cell
{'sample = 889'}
I want to get a cell containing the text 'line, sample' without directly entering the index value.

채택된 답변

KSSV
KSSV 2022년 2월 24일
Read about contains, strcmp, strcmpi, strfind. All these functions give you index where theres is a match with the given input string.
If C is your nx1 cell array.
idx = contains(C,'line = 5457') ;
iwant = C(idx)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by