MATLAB Answers

Filter out combinations of letters

2 views (last 30 days)
Christopher Syhr
Christopher Syhr on 8 Jul 2021
Commented: Jonas on 8 Jul 2021
Hi,
I have created around 7 Million Combinations of Letters and Number.
This how the 7077888×6 char matrix looks like (i did not include the number 0 (zero) and 1 (one).
'A2A2A2'
'A2A2A3'
.....
'Z9Z9Z9'
Now i want to delete the rows, which include certain combinations of letters. Let's say I want to delete all the rows, which include the letters
"D I C" in that exact order. I have tried to use the code
indices = find(C =='D2I2C2');
to manually find the row in which one of the combination is located, but that did not work.
I hope you can help me out!
Thank you very much!
  2 Comments
Christopher Syhr
Christopher Syhr on 8 Jul 2021
To clarify what I meant: D[Number]I[Number]C[Number] is the format I am trying to filter out.
'D2I2C2'
is just an example of many, that i want to delete. Sorry for the confusion.

Sign in to comment.

Accepted Answer

Jonas
Jonas on 8 Jul 2021
do you mean the case if the three letters that occur are D, I and C?
in=['D3I2C7';'B4H8R1'];
out=regexprep(cellstr(in),'D.I.C.','');
vertcat(out{:})
  2 Comments
Jonas
Jonas on 8 Jul 2021
you can directly add it in regexprep
in=['D3I2C7';'B4H8R1';'Z3G4K2'];
out=regexprep(cellstr(in),{'D.I.C.','B.H.R.'},'');
vertcat(out{:})

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!