No BSD License  

Highlights from
Merge matrices

5.0

5.0 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 2.99 KB File ID: #21229
image thumbnail

Merge matrices

by

 

26 Aug 2008 (Updated )

(in a SQL equijoin)

| Watch this File

File Information
Description

Function JOINMAT implements SQL 'join' operation with a single equality condition.

http://en.wikipedia.org/wiki/Join_(SQL)

It has been tested with numeric keys only, and not optimized; improvements are enthusiastically welcomed.

See also the dataset-array version JOINDST.

PS. Note that output rows are sorted, and Inf values are treated in the same way as (but are distinguished from) NaN values.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
17 Nov 2010 David Divad

Unfortunately this does not seem to work always well.

Consider:

A = [1 1; 1 2; 1 3; 1 4]
C = [1 8; 1 9]
joinmat(A,C,'inner') % does not give cartesian product -> joinmat only works with unique keys in at least one of the matrices

ans =

1 1 8
1 2 9
1 3 8
1 4 9
1 1 8
1 2 9
1 3 8
1 4 9

Does anybody know a good alternative to this? How can I join two matrices in MATLAB (without unique keys)?

03 Nov 2010 Jesse Blocher

Brilliant - this saved me a ton of time from either setting up mySQL or otherwise exporting out of Matlab elsewhere to do the join. Again, brilliant.

07 Sep 2008 Phil from AL

Just what I was looking for. Wonder why MW released a 'join' (kinda) for datasets but not for matrices.

Contact us