Filter out combinations of letters

1 visualizzazione (ultimi 30 giorni)
Christopher Syhr
Christopher Syhr il 8 Lug 2021
Commentato: Jonas il 8 Lug 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 Commenti
Scott MacKenzie
Scott MacKenzie il 8 Lug 2021
Your question is confusing. In your example, is the letter sequence D, space, I, space, C? If not, explain. If so, why are you using the letter sequence D2I2C in the find function?
Christopher Syhr
Christopher Syhr il 8 Lug 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.

Accedi per commentare.

Risposta accettata

Jonas
Jonas il 8 Lug 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 Commenti
Christopher Syhr
Christopher Syhr il 8 Lug 2021
This works very well. If I wanted to include more combination of letters, say for example D[Number]I[Number]C[Number], S[Number]U[Number]C[Number], F[Number]U[Number]C[Number], could I expand the code, or do I need to run the code subsequently?
Thank you so much for your help!!
Jonas
Jonas il 8 Lug 2021
you can directly add it in regexprep
in=['D3I2C7';'B4H8R1';'Z3G4K2'];
out=regexprep(cellstr(in),{'D.I.C.','B.H.R.'},'');
vertcat(out{:})

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Time Series Collections in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by