Matching the maximum Values in a matrix from another vector

1 回表示 (過去 30 日間)
Yaser Khojah
Yaser Khojah 2018 年 10 月 15 日
コメント済み: Yaser Khojah 2018 年 10 月 16 日
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 件のコメント
Yaser Khojah
Yaser Khojah 2018 年 10 月 15 日
@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 2018 年 10 月 15 日
"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.

サインインしてコメントする。

採用された回答

Andrei Bobrov
Andrei Bobrov 2018 年 10 月 15 日
lo = ismembertol(STD_v,xvalues,.01,'DataScale',1);
Matrix_Vector_updated = [STD_v(lo),NPV_v(lo)];
  1 件のコメント
Yaser Khojah
Yaser Khojah 2018 年 10 月 16 日
Thanks a lot Andrei for your answer and many thanks to @Stephen.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by