1

I have two tables of different row size (which may vary). The variable name is different (no variable name in common). When I try to join these I get an error that no keys are common. Is there a command that would join these two tables? Or how can do this best?

t1=
Var1
a
b
c

t2=
Var2
1
2

I would like to end up with:

t3=
var1 Var2
a 1
b 1
c 1
a 2
b 2
c 2

I tried join, innerjoin and outerjoin but did not get it to work. I am probably missing something... preferably I would like to join an arbitrary number of tables.

Erik
  • 71
  • 2
  • 12
  • `repmat` might work for you. I'd rather use something like `meshgrid` but that doesnt work with char-variables if Im not mistaken. – Adriaan Aug 29 '15 at 11:56
  • it is important that it works with text and digits. I would have to write a custom function with repmat() in it to "expand" the tables? – Erik Aug 29 '15 at 22:09

1 Answers1

1

Use a dummy variable Var3 = 1 for every row in both tables. Now you have a common column. OUTERJOIN works and at the end delete Var3.

Justin Howard
  • 5,504
  • 1
  • 21
  • 48