strcmp function using wildcards

조회 수: 27 (최근 30일)
sermet OGUTCU
sermet OGUTCU 2021년 11월 24일
답변: Stephen23 2021년 11월 24일
data= 336950 x 2 table
I try to find all rows in data containing "G[0-9][0-9]" such as G01, G09, G33 and etc. I tried the following code:
G_index=find(strcmp('G**',data(:,2)));
but ** cannot be recognized as wildcards.

채택된 답변

Stephen23
Stephen23 2021년 11월 24일
T = cell2table({'A','XXX';'B','G22';'C','G13';'D','G1234';'E','YYY';'F','G01'})
T = 6×2 table
Var1 Var2 _____ _________ {'A'} {'XXX' } {'B'} {'G22' } {'C'} {'G13' } {'D'} {'G1234'} {'E'} {'YYY' } {'F'} {'G01' }
idx = ~cellfun(@isempty,regexp(T.Var2,'^G\d\d$','once'))
idx = 6×1 logical array
0 1 1 0 0 1

추가 답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 11월 24일
  댓글 수: 1
sermet OGUTCU
sermet OGUTCU 2021년 11월 24일
Could you give an example its usage for this data table?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by