Merge two sorted vectors into a sorted vector

Merge two sorted vectors 'a' and 'b' into a sorted vector 'c'
4.0K 次下载
更新时间 2009/7/9

查看许可证

mergesorted.m
------------------
If we have two individually sorted vectors "a" and "b" but they are not sorted with respect to each other and we want to merge them into vector "c" such that "c" is also a sorted vector. Then c=mergesorted(a,b) can be used.

This function most likely make difference for very large vectors (may be elements in million). On P-4 machine when length of "a" is 2 million and length of "b" is 2.5 million then c=mergesorted(a,b) is around 3 times faster than using MATLAB builtin function c=sort([a,b]).

testmergesorted.m
----------------------
A simple test program to that test "mergesorted" and builtin "sort" function and compare their performance.

引用格式

Dr. Murtaza Ali Khan (2024). Merge two sorted vectors into a sorted vector (https://www.mathworks.com/matlabcentral/fileexchange/8097-merge-two-sorted-vectors-into-a-sorted-vector), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14SP1
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

mergesortedvectors/

版本 已发布 发行说明
1.1.0.0

BSD License

1.0.0.0