Azzera filtri
Azzera filtri

Find subvector/submatrix within matrix (with place holder)

3 visualizzazioni (ultimi 30 giorni)
Hello,
I want to find specific patterns, which are not connected in a matrix.
For example.
The complete vector is a = [1 2 3 4 5 6 8 10]
and now I want to find b = [1 2 X 4], X should be some place holder, I don't care about the value there.
This would be the 1d case, but I'm also interested in the 2d case.
Does anyone have a good idea for the implementation or already code fragments?
Thanks

Risposte (1)

Image Analyst
Image Analyst il 7 Lug 2017
The wildcard makes it tricky. Probably strfind() or regexp(). It will be very cryptic, but someone (Andrei, etc.) will know how.
Or you can use a brute force, but easy-to-understand way of scanning element by element looking for a match. In 2-D you can use nlfilter(), in the Image Processing Toolbox, to help.

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by