How to remove vectors values with restraints?

1 view (last 30 days)
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

Answers (1)

David Fletcher
David Fletcher on 5 Apr 2021
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

Community Treasure Hunt

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

Start Hunting!