strcmp function using wildcards

27 Ansichten (letzte 30 Tage)
sermet OGUTCU
sermet OGUTCU am 24 Nov. 2021
Beantwortet: Stephen23 am 24 Nov. 2021
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 24 Nov. 2021
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

Weitere Antworten (1)

Yongjian Feng
Yongjian Feng am 24 Nov. 2021
  1 Kommentar
sermet OGUTCU
sermet OGUTCU am 24 Nov. 2021
Could you give an example its usage for this data table?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by