Merge sorted arrays

Given two already sorted arrays, the function combines them in an unique sorted array
Updated 4 Nov 2013

View License

Using this function avoids to call Matlab SORT(), which does unnecessary work since the two inputs is already sorted.

Mex implementation for speed.
'rows' option supported

Cite As

Bruno Luong (2024). Merge sorted arrays (, MATLAB Central File Exchange. Retrieved .

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

Inspired: ChooseK

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Fix bug of merge rows with empty array

Minor speed improvement

Optionally return the splitting locations of the inputs