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

4 views (last 30 days)
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

Accepted Answer

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

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!