How to operate on One Column of A matrix while the other Columns stay connected row-wise to the column we are operating on
2 views (last 30 days)
Show older comments
Arief Yoga Randytama
on 17 May 2021
Commented: Arief Yoga Randytama
on 17 May 2021
Hi, sorry for bad wording but suppose i have this matrix
A =
1 2
1 3
2 5
2 4
4 2
6 1
8 1
I want to find the maximum of the first column while still connect the second value to the output for example if i ask the output of max 1st column of A itu will return the value of :
8 1
moreover, I want to rank the matrix from the largest value, based on column 1 while still connect the first column to the second, the desired output is this:
8 1
6 1
4 2
2 5
2 4
1 3
1 2
how can i do that?
lastly i want to find the average of the third largest value of the above matrix, based on the value of the first column, column wise. The desired output is this:
6 1.333
again, I'm sorry for bad wording, Any help will be greatly appreciated.
0 Comments
Accepted Answer
Maxi
on 17 May 2021
first problem could be solved with
index_max=find(max(A(:,1))==A(:,1)) %find the index of the largest value in the first column
A(index_max,:)
>>ans =
8 1
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!