I'm trying to take matrix (A) & search matrix (B) for matching rows (matching columns 1-5) and retrieve the value from (B) column 6 to be added to matrix (A) column 6.
A={1 1 1 1 1 2; 1 1 1 1 2 3; 1 1 1 1 3 1; 1 1 1 1 4 2; 1 1 1 1 5 8; 1 1 1 1 6 3; 1 1 1 1 7 1; 1 1 1 1 8 0; 1 1 1 1 9 9; 1 1 1 2 0 2};B={1 1 1 1 2 1; 1 1 1 1 4 1; 1 1 1 1 6 2; 1 1 1 2 0 3; 1 1 1 1 9 3; 1 1 1 1 1 0; 1 1 1 1 3 0; 1 1 1 1 5 0; 1 1 1 1 7 4; 1 1 1 1 8 8};% Find A's match within B's matrix
[~,~,ib] = intersect(A(:, 1:5), B(:, 1:5), 'rows');% Get Adjustment (Column 6) values from B
adjustment = B(ib, 6);% Apply Adjustments to B
for z = 1:length(RxPDW) A(z,6) = sum(A(z,6),adjustment(z,1));end
I'm trying get a result of
A={1 1 1 1 1 2; 1 1 1 1 2 4; 1 1 1 1 3 1; 1 1 1 1 4 3; 1 1 1 1 5 9; 1 1 1 1 6 5; 1 1 1 1 7 9; 1 1 1 1 8 13; 1 1 1 1 9 12; 1 1 1 2 0 9}
Best Answer