Filter löschen
Filter löschen

How to remove the values in vector 'B' corresponding to 'NaNs' in vector 'A'?

1 Ansicht (letzte 30 Tage)
Hello every one, I have two vectors as a sample
A=[10 12 15 NaN 20 30 46 NaN 12 10 NaN 9 8 7 8 NaN 51 Nan 24]
B=[11 73 24 36 47 18 29 31 52 44 33 22 28 16 15 13 19 18 13]
I can delete the 'NaNs' from vector 'A' by using a function
A(isnan(A)) = [];
but I also want to delete the values in vector 'B' corresponding to 'NaNS' in vector 'A'. I want to get
A=[10 12 15 20 30 46 12 10 9 8 7 8 51 24]
B=[11 73 24 47 18 29 52 44 22 28 16 15 19 13]
I do not know how to get it. Any help will be appreciated.
Thanks

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 3 Jun. 2018
index=isnan(A)
B(index) = [];

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by