MATLAB: Updating an array elements with elements from another Array

array manipulation

Hello, Could I please get some assistance on how to update array elements with elements from another array, For example
A = rand(10,10);
B = rand(10,10);
Result = A-B;
%Identifty which elements are greater than 0
SlctElemnts = Result > 0 ;
%%Update all the elements in A that is less than 0 with the element in B
% A (Result<0);
disp(A)

Best Answer

How about something like this:
A = rand(10,10);
B = rand(10,10);
Result = A-B;
LogicalIndex= Result<0;
A(LogicalIndex)=B(LogicalIndex);