Checking if word/words are present in a sentence in a table cell.

조회 수: 5 (최근 30일)
Maria Pati
Maria Pati 2019년 7월 31일
댓글: Maria Pati 2019년 8월 1일
I need help about a code on how to check if words like "M3 TRIPPED" is present in the sentence of the table cells, and output a matrix indicating the row number and column where this phrase is present.
Thank you.

채택된 답변

Image Analyst
Image Analyst 2019년 7월 31일
Try contains().
if contains(ca{2, 1}, 'M3 TRIPPED')
% It contains that phrase in row 2, column 1 of cell array called ca
% etc. more code...
Attach your cell array in a .mat file if you need more help.

추가 답변 (2개)

madhan ravi
madhan ravi 2019년 7월 31일
편집: madhan ravi 2019년 7월 31일
[Rows,Columns]=find(strcmp(T{:,:},'M3 TRIPPED')) % T your table

Akira Agata
Akira Agata 2019년 7월 31일
Like this?
% A sample data
T = cell2table({...
'M3 TRIPPED xyz','abc','pqr';...
'def','M3 TRIPPED 123','ghi'});
% Find row and column containing 'M3 TRIPPED'
idx = contains(T{:,:},'M3 TRIPPED');
[row,col] = find(idx);

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by