Compare elements from two matrix.
Mostrar comentarios más antiguos
Hi!
I want to compare elements for two matrix and then create another matrix with maximal element (comparing abs(x1) i abs(x2), not x1 i x2).
I wrote this:
But maybe it's possible to do it quicker and more efficient?
for i = 1:numel(x1)
if (abs(x1(i)) > abs(x2(i)))
x(i) = x2(i);
else
x(i) = x1(i);
end
end
Respuesta aceptada
Más respuestas (1)
Olawale Ikuyajolu
el 13 de Mayo de 2020
new_matrix = max(abs(x1),abs(x2);
3 comentarios
Nikita Zyk
el 13 de Mayo de 2020
Olawale Ikuyajolu
el 13 de Mayo de 2020
Nikita Zyk
el 13 de Mayo de 2020
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!