|
"BobC Cadenza" <bobc@mailinator.com> wrote in message <i8t6bc$7ih$1@fred.mathworks.com>...
> I have two matricies, with one column in each that is unique and I will call the index. I want to merge the matricies so that I have a new matrix that contains each row from each matrix that each have the same index. How can i do this? Below is a simple example. Thanks in advance.
>
> mat1 = [[1.2 4.2 datenum(today);5.2 2.4 datenum(today-1);2.4 1.2 datenum(today-3)];
>
> mat2 = [[1.2 34.2 datenum(today)32.4 11.2 datenum(today-3)];
>
> result = [[1.2 4.2 1.2 34.2 datenum(today);2.4 1.2 32.4 11.2 datenum(today-3)];
- - - - - - - - - -
Your description leaves much to be desired as to its clarity. This is my best guess of what you mean:
[c,i1,i2] = intersect(mat1(:,3),mat2(:,3));
result = [mst1(i1,1:2),mat2(i2,1:2),c];
Roger Stafford
|