Finding Patterns in Array

13 vues (au cours des 30 derniers jours)
Mohamed Jamal
Mohamed Jamal le 29 Juin 2020
Commenté : Turlough Hughes le 9 Juil 2020
Hi guys, how do I find in my specific binary pattern in another array that has binary values? I mean lets assume I have
a=[1 0 1] (binary values)
the other array b=[1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1] (binary values)
So Im searching inside b about a which I want to return the started index of my pattern in other other array, any help how could I implement that?

Réponses (1)

Voss
Voss le 29 Juin 2020
Look into strfind.
idx = strfind(b,a); % strfind implicitly converts a and b to char arrays
  3 commentaires
Voss
Voss le 5 Juil 2020
strfind does the job.
Turlough Hughes
Turlough Hughes le 9 Juil 2020
Your vectors a, and b remain unchanged. The output of strfind is a start index for each occurence of a in b as you requested.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by