MATLAB: How can i create a matrix with samples from irregular X,Y

unpaired matrix

Example:
Am01= (x;y) = (1 2 3 4 5 ; 10 20 30 40 50)
Am02= (x;y) = (1 3 4 ; 30 20 50)
Am03= (x;y) = (1 2 5 ; 25 93 47)
Matrix Funded:
x - y1 - y2 - y3
1 10 30 25
2 20 0 93
3 30 20 0
4 40 0 0
5 50 50 47

Best Answer

One possible solution would be like this:
Am01 = [1 2 3 4 5 ; 10 20 30 40 50]';
Am02 = [1 3 4 ; 30 20 50]';
Am03 = [1 2 5 ; 25 93 47]';
x = unique([Am01(:,1) ; Am02(:,1) ; Am03(:,1)]);
A = zeros(numel(x),4);
A(:,1) = x;
[~,loc] = ismember(Am01(:,1),A(:,1));
A(loc,2) = Am01(:,2);
[~,loc] = ismember(Am02(:,1),A(:,1));
A(loc,3) = Am02(:,2);
[~,loc] = ismember(Am03(:,1),A(:,1));
A(loc,4) = Am03(:,2);
The output is:
>> A
A =
1 10 30 25
2 20 0 93
3 30 20 0
4 40 50 0
5 50 0 47