No BSD License  

Highlights from
Merge matrices

5.0

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

Merge matrices

by Dimitri Shvorob

 

26 Aug 2008 (Updated 27 Aug 2008)

(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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
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.

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.

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)?

Please login to add a comment or rating.
Updates
27 Aug 2008

link to JOINDST

Tag Activity for this File
Tag Applied By Date/Time
matrices Dimitri Shvorob 22 Oct 2008 10:16:13
join Dimitri Shvorob 22 Oct 2008 10:16:13
merge Dimitri Shvorob 22 Oct 2008 10:16:13
sql Dimitri Shvorob 22 Oct 2008 10:16:13
matrix manipiltaion Dimitri Shvorob 22 Oct 2008 10:16:13
utilities Dimitri Shvorob 22 Oct 2008 10:16:13
sql Annette 12 Oct 2010 14:53:25
join asmat khan 03 Nov 2010 21:37:47

Contact us at files@mathworks.com