How to remove vectors values with restraints?

2 ビュー (過去 30 日間)
Antonio Alves
Antonio Alves 2021 年 4 月 5 日
回答済み: David Fletcher 2021 年 4 月 5 日
I'm with two distinct vectors that shouldn't have, in the same column, values that would sum up to >=1.
Ex:
A = [ 0.1 0.2 0.4 0.6]
B = [ 0.5 0.9 0.6 0.2]
Since 0.2 + 0.9 = 1.1 and 0.4 + 0.6 = 1, what I would need is a code that would turn this set of vectors into:
A = [ 0.1 0.6] B = [0.5 0.2]
How can I do that? I have no clue where to start

回答 (1 件)

David Fletcher
David Fletcher 2021 年 4 月 5 日
A = [ 0.1 0.2 0.4 0.6]
B = [ 0.5 0.9 0.6 0.2]
C=(A+B)<1
A=A(C)
B=B(C)
C =
1×4 logical array
1 0 0 1
A =
0.1000 0.6000
B =
0.5000 0.2000

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by