MATLAB: Merging/Superimposing two tables without using loops

MATLABtable

I have two very large (200000×200) tables, Table_1 & Table_2. They have columns/variables that store different data types- strings, doubles, integers etc.
I want to create a third table, Table_3, that superimposes Table 2 over Table 1 if Table 1 has a missing value. i.e.
if Table_1(row,column)<>{''},
Table_3(row,column)=Table_1(row,column)
else
Table_3(row,column)=Table_2(row,column)
For example,
Table 1 Table 2 Table 3
Record Name Age Record Name Age Record Name Age
1 John 10 1 John 1 John 10
2 Daniela 2 Daniela 5 2 Daniela 5
3 Austin 30 3 Austin 30 3 Austin 30
4 45 4 Mark 45 4 Mark 45
I want to do this without using for loops because the time to traverse them is very very slow.
To consider:
  • Is there a way to do this using the fillmissing() function? This would be the most natural approach however, Table_3=fillmissing(Table_1,'Constant',Table_2) doesn't work. (The 2nd argument (Table_2) cannot be multidimensional.)
  • If this were a simple matrix, Table_3(Table_1=='')=Table_2 would've worked; but I can't seem to do this with tables.
Thanks, NT

Best Answer

This isn't exactly a join, but it's close. It's not entirely clear to me what you want to do, for example, Mark is missing from reconrd 4 in table 1, but Age == 45 is not. However, in tables 2 and 3, where Mark is present, it's the same Age: 45. Is that always true? If so, I would think you could delete records from table 1 that had missing values, then outerjoin with table 2, then repeat for table 3.
Otherwise, maybe you're looking for some kind of setdiff operation.