Identify interval completion by strings

8 visualizaciones (últimos 30 días)
TF Lew
TF Lew el 11 de Dic. de 2021
Comentada: TF Lew el 18 de Dic. de 2021
I have an array of strings representing various intervals from human-entered data. E.g.,
startA
startB
on
endA
off
endB
...
I need to ensure each unique start is followed by its unique stop, not containing another unique start within that interval or vice versa for ends. If this does occur, I need to return the indices of the previous and following string, e.g. (startA -> missing end -> startA, return both startAs). I'm struggling to find an eluquent solution for this.

Respuestas (1)

Image Analyst
Image Analyst el 11 de Dic. de 2021
Try using strfind() or contains() or ismember() to identify indexes where specific words occur.
  3 comentarios
Image Analyst
Image Analyst el 13 de Dic. de 2021
Attach the file with the words in it. I think you need to use readcell() on that file to import those words into a cell array.
TF Lew
TF Lew el 18 de Dic. de 2021
I realized the error of my ways -- simply using a find(contains()) allowed me to create individual arrays of the interval markers rather than attempting to do it all in nested loops, e.g.,
startFeedbacks = find(contains(episode.marker, 'startFeed'));
endFeedbacks = find(contains(episode.marker, 'endFeed'));
allowing liberty for typos (checked in a seperate function but additional precautionary).
From this I could simply run through each two pairing arrays and 1) check for height equality and 2) find the index range (or start/end index) wherein a missing marker should exist.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Identification en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by