Filter out combinations of letters

2 visualizaciones (últimos 30 días)
Christopher Syhr
Christopher Syhr el 8 de Jul. de 2021
Comentada: Jonas el 8 de Jul. de 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 comentarios
Scott MacKenzie
Scott MacKenzie el 8 de Jul. de 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 el 8 de Jul. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Jonas
Jonas el 8 de Jul. de 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 comentarios
Christopher Syhr
Christopher Syhr el 8 de Jul. de 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 el 8 de Jul. de 2021
you can directly add it in regexprep
in=['D3I2C7';'B4H8R1';'Z3G4K2'];
out=regexprep(cellstr(in),{'D.I.C.','B.H.R.'},'');
vertcat(out{:})

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Time Series Collections en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by