简体   繁体   中英

How to find a corresponding value in a table in Matlab

In Matlab, I am given a table with two columns. Now I want to find the corresponding value of the left column to the maximum value of the right column:

P1_sat = P1(ismember(P2,max(P2)))

This works, however, the maximum is identical at 3 values of the left column, P1. These 3 values are right next to each other. So I want to consider the mid value. Is there a "consider the mid value" - command?

Adding the following code line will complete my goal:

 P1_sat = sum(P1_sat,1) / length(P1_sat)

The three different values of P1, whose corresponding value of P2 is the maximum of P2, are added and then divided by 3. This gives the average value, which is also the mid point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM