Matching the maximum Values in a matrix from another vector
조회 수: 4 (최근 30일)
이전 댓글 표시
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
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
2018년 10월 15일
lo = ismembertol(STD_v,xvalues,.01,'DataScale',1);
Matrix_Vector_updated = [STD_v(lo),NPV_v(lo)];
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!