Pattern matching - MATLAB Cody - MATLAB Central

Problem 59. Pattern matching

Difficulty:Rate

Given a matrix, m-by-n, find all the rows that have the same "increase, decrease, or stay same" pattern going across the columns as the first row does. Do not list the row as a match to itself.

Example:

 Input  a = [1 2 3 0
             5 6 7 9
             2 7 8 7]
 Output b is 3

since the third column follows the increase-increase-decrease pattern used in vector a.

Solution Stats

52.86% Correct | 47.14% Incorrect
Last Solution submitted on Jun 22, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
2
3

Problem Recent Solvers2776

Suggested Problems

More from this Author96

Problem Tags

Community Treasure Hunt

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

Start Hunting!