How to remove vectors values with restraints?

2 visualizaciones (últimos 30 días)
Antonio Alves
Antonio Alves el 5 de Abr. de 2021
Respondida: David Fletcher el 5 de Abr. de 2021
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

Respuestas (1)

David Fletcher
David Fletcher el 5 de Abr. de 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

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by