I have 2 tables in MATLAB, table X and Table Y each of different dimensions. Table X and Table Y both contain a column named Code. Table X has the last column as LabelX (an empty column) and Table Y has the Last Column LabelY (with label values as strings). What I would like to achieve is that for all elements in Table X, I would like to add the Label from Table Y's LabelY corresponding to the Code. So, for example if Code is 1 in table X, MATLAB would look for the LabelY in Table Y's LabelY column and then append the same label to Table X's LabelX Column. I tried using for loops for this purpose but I don't feel that it is a good way or if I am doing it correctly. Any help in this regard would be appreciated.
for i = 1:size(TableX,1) for j = 1:size(TableY,1) if(TableX.Code(i) == TableY(j)) TableA.Label(i) = LDTUniqueAlarmListv3.FunctionalGrouping(j); end endend
Best Answer