Merge two sorted vectors into a sorted vector
by Dr. Murtaza Khan
25 Jul 2005
(Updated 09 Jul 2009)
Merge two sorted vectors 'a' and 'b' into a sorted vector 'c'
|
Watch this File
|
| File Information |
| Description |
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. |
| MATLAB release |
MATLAB 7.0.1 (R14SP1)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (1) |
| 02 Nov 2007 |
Jhonty R.
|
|
|
| Updates |
| 09 Jul 2009 |
BSD License |
|
Contact us at files@mathworks.com