Extract maximum value out of two column in a row & delete the last row

2 visualizaciones (últimos 30 días)
Hello:
I have two matrix A and B as below. I need to extract maximum value out of column 6th and 7th and delete the last column.
1 6337100 52.17 8.86 0.10 0.22 0.33
1 6337200 52.96 9.12 0.08 0.19 0.36
1 6338100 52.74 7.24 0.15 0.27 0.30
1 6338110 52.59 7.24 0.19 0.30 0.39
1 6338130 52.28 7.43 0.21 0.32 0.38
1 6340110 53.23 10.8 0.03 0.09 0.29
1 6340210 53.65 10.0 0.30 0.35 0.19
1 6340216 53.57 10.0 0.28 0.35 0.26
Output matrix
1 6337100 52.17 8.86 0.1 0.33
1 6337200 52.96 9.12 0.08 0.36
1 6338100 52.74 7.24 0.15 0.3
1 6338110 52.59 7.24 0.19 0.39
1 6338130 52.28 7.43 0.21 0.38
1 6340110 53.23 10.8 0.03 0.29
1 6340210 53.65 10 0.3 0.35
1 6340216 53.57 10 0.28 0.35

Respuesta aceptada

dpb
dpb el 26 de Jul. de 2019
B=[A(:,1:end-2) max(A(:,end-1:end),[],2)]

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by