Updating an array elements with elements from another Array
Mostra commenti meno recenti
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)
Risposta accettata
Più risposte (1)
Ameer Hamza
il 26 Mag 2018
Modificato: Ameer Hamza
il 26 Mag 2018
For indexing based solution, refer to Rik's answer. But in this specific case, you are trying to find the element-wise maximum value from both A and B. So you can do it faster using max() function,
A = max(A, B)
1 Commento
Zaharaddeen Hussaini
il 27 Mag 2018
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!