extracting a particular element from a matrix

Hi all,
I have a column matrix A (with some common elements in it) and another column matrix B, I have added both the matrices (let the final matrix formed is C). Now I want to extract that element from C, which is formed by the max. value among common elements in A and its corresponding element in B
Suppose
A=[1
2
5
5
10
10
10]
B=[1
3
4
5
7
1
6]
Please help to have my answer as 17 from (5th element of A + 5th element of B
Here both A & B are user defined thus the size and index values may differ

댓글 수: 6

why not just:
[Value,Index]=max(A+B)
TADA
TADA 2019년 2월 22일
I Didn't Understand Exactly What you want.
Are You Trying To Find The Maximal Value Of C, I.E 17, Or The Maximal Value For Each Group Of Numbers In A, I.E [2; 5; 10; 17] Corresponding To The Number In A: [1; 2; 5; 10]
What Have You Tried So Far?
Also I Have To Ask, Is The Next Number In A 17?
Jan
Jan 2019년 2월 22일
@madhan: I assume your code is the solution. Please post it as answer.
@Jan: Done :-)
Actually matrix c should be made by taking max. values from A and adding with it the corresponding element in B ( ie. if a(12) and a(13) are the max velues of A then add b(12) with a(12) and b(13) with a(13))
The new column matrix is [ a(12)+b(12)
a(13)+b(13)]
madhan ravi
madhan ravi 2019년 2월 23일
편집: madhan ravi 2019년 2월 23일
You say max but why do you say a(12) & a(13) , completely vague and unclear. See if maxk() does your job.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2019년 2월 25일

0 개 추천

A bold guess:
index = (A == max(A));
A(index) + B(index)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2019년 2월 22일

답변:

Jan
2019년 2월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by