Matching the maximum Values in a matrix from another vector

1 vue (au cours des 30 derniers jours)
Yaser Khojah
Yaser Khojah le 15 Oct 2018
Commenté : Yaser Khojah le 16 Oct 2018
I have a matrix with size of 21600 x 2 as Matrix_Vector = [STD_v,NPV_v]; I'm trying to find the values that matching xvalues = [0:.1:35] from STD_V.
So, I used this code:
[ d, ix ] = min( abs( STD_v-xvalues ) );
Matrix_Vector_updated = [STD_v(ix),NPV_v(ix)];
However, I still see values in Matrix_Vector_updated share the same values as 0.468 as below:
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.468490416082415 -68.0623566640544
0.861091227948802 -62.0460361812610
0.861091227948802 -62.0460361812610
0.920662009016715 -52.2025156248263
0.920662009016715 -52.2025156248263
1.08087425638995 -34.5197924821680
1.21018219911556 -45.0147047153047
1.31409003462488 -62.4048732765717
1.40064375002948 -49.6318599064140
1.50221080043184 -60.8266330903523
1.61795597497108 -48.3442487471706
1.68219041491832 -37.6318990471176
I'm trying to limit my numbers to the following format where I get only one value from NPV_v (the maximum if there is more than a value) corresponding to each value in STD_V:
0
0.100000000000000
0.200000000000000
0.300000000000000
0.400000000000000
0.500000000000000
0.600000000000000
0.700000000000000
0.800000000000000
0.900000000000000
1
Can anyone help please
  4 commentaires
Yaser Khojah
Yaser Khojah le 15 Oct 2018
@Stephen, I tried it but did not work. @ Bruno, I have used this in my code but I just want to select the maximum value for each values sharing the same numbers. So, manually would be:
if true
0.468490416082415 -68.0623566640544
0.861091227948802 -62.0460361812610
0.920662009016715 -52.2025156248263
1.08087425638995 -34.5197924821680
1.21018219911556 -45.0147047153047
1.31409003462488 -62.4048732765717
1.40064375002948 -49.6318599064140
1.50221080043184 -60.8266330903523
1.61795597497108 -48.3442487471706
1.68219041491832 -37.6318990471176
end
Bruno Luong
Bruno Luong le 15 Oct 2018
"just want to select the maximum value"
I'm just unsure what you meant by that. You list a bunch of numbers without commenting where they come from.
And those number inside the odd IF
if true
....
end
This kind of language is not what I can read and interpret.

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 15 Oct 2018
lo = ismembertol(STD_v,xvalues,.01,'DataScale',1);
Matrix_Vector_updated = [STD_v(lo),NPV_v(lo)];
  1 commentaire
Yaser Khojah
Yaser Khojah le 16 Oct 2018
Thanks a lot Andrei for your answer and many thanks to @Stephen.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by