It's more challenging if all tables do not have all the variables. MATLAB will fill the unassigned variable(s) with the default value for the datatype. That is 0 for doubles, not NaN (see the warning message below)
T1 = table(org01,org02,SQ001)
T1 =
org01 org02 SQ001
_____ _____ _____
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
T2 = flip(T1(:,["SQ001","org01"]))
T2 =
SQ001 org01
_____ _____
5 5
4 4
3 3
2 2
1 1
T1(end+1:end+height(T2),T2.Properties.VariableNames)=T2
Warning: The assignment added rows to the table, but did not assign values to all of the table's existing variables. Those variables are extended with rows containing default values.
T1 =
org01 org02 SQ001
_____ _____ _____
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
5 0 5
4 0 4
3 0 3
2 0 2
1 0 1
If you really want them to be NaN, there are a couple options. If you want to make all 0s NaN, look into the standardizemissing function. If there will be zeros elsewhere you don't want to change to NaN, you can use a comparison of variable names along with some indexing to set just the extended variables to NaN. Here's an eample. T1{end-height(T2)+1:end,~ismember(T1.Properties.VariableNames,T2.Properties.VariableNames)}=NaN
T1 =
org01 org02 SQ001
_____ _____ _____
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
5 NaN 5
4 NaN 4
3 NaN 3
2 NaN 2
1 NaN 1
Best Answer