I am looking for methods, built-in functions, good practices... to append new data to a matrix - when the rows and columns are not the same
The data
Here is a solution using unique
and indexing:
%combine the data and take unique value of them + their index
[C.id,~,date_i] = unique([A.dates(:);B.dates(:)]);
[C.dates,~,id_i] = unique([A.id B.id]);
C.values = nan(numel(C.dates),numel(C.id));
%use matrix indexing to fill the sub-materices corresponding to elements of A and B
C.values(date_i(1:numel(A.dates)),id_i(1:numel(A.id)))=A.values;
C.values(date_i(numel(A.dates)+1:end),id_i(numel(A.id)+1:end))=B.values;