Version (1.17 KB) by David
Matches two sorted one-dimensional arrays, with the output Nan-Matched
Updated 11 Apr 2016

View License

This function "matches" two one-dimensional arrays together. The result is a 2-column matrix, where each row of the matrix contains the original elements of each array. If the arrays do not match each other at a certain index, then in the resulting matrix the array not containing that value will contain a NaN at that row. Each one-dimensional array should be sorted before passing it to this function.
For example, the input arrays [1 2 3 3 3 4 5] and [1 2 3 5 6 7] will be matched to look as follows: [1 2 3 3 3 4 5 nan nan; 1 nan 3 3 nan nan 5 6 7].

Cite As

David (2024). MatchArrays (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Matrices and Arrays in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes