You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
This function searches for an n-dimentional pattern in a k-dimentional array.
Its output is the linear indices of the beginnings of matches. Matches can overlap.
There are 2 debug blocks: the first is for generation of a random array & pattern, and the second is for output check using subscripts and ranges.
I tested the function on random 0-9-dimentional arrays and patterns, and on arrays which were repmats of patterns (to compare performance when there are a lot of matches with performance when there aren't).
- Note that NaN's are not equal to each other, and will not match.
Much thanks goes to whoever wrote ind2sub, as I took some ideas from it for the n-dimentional loop.
Cite As
Anan Yablonko (2026). arraypat (https://www.mathworks.com/matlabcentral/fileexchange/110855-arraypat), MATLAB Central File Exchange. Retrieved .
General Information
- Version 1.0.1 (1.93 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
