MATLAB Answers

0

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

Asked by Poulomi Ganguli on 26 Jul 2019
Latest activity Answered by dpb
on 26 Jul 2019
Accepted Answer by dpb
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

  0 Comments

Sign in to comment.

1 Answer

Answer by dpb
on 26 Jul 2019
 Accepted Answer

B=[A(:,1:end-2) max(A(:,end-1:end),[],2)]

  0 Comments

Sign in to comment.