How to get the max value between two elements of two separate arrays?

32 visualizaciones (últimos 30 días)
Hello everyone, thanks for reading
What I'm trying to do is this:
I have these two arrays:
a= [1,3,4,6]
b= [2,2,5,4]
I want to get a new 'c' array with the max values of a comparison between each element of 'a' and 'b'
this -----------> c= [2,3,5,6]

Respuesta aceptada

Eric Delgado
Eric Delgado el 21 de Oct. de 2022
Try this...
a= [1,3,4,6];
b= [2,2,5,4];
max([a;b])
ans = 1×4
2 3 5 6

Más respuestas (1)

Stephen23
Stephen23 el 21 de Oct. de 2022
The efficient MATLAB approach:
a = [1,3,4,6];
b = [2,2,5,4];
c = max(a,b)
c = 1×4
2 3 5 6

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by