Have one array follow another array with a threshhold

1 view (last 30 days)
Hi there! I've got two arrays and I want to put a threshhold on one of them and have the other array follow it (see example down below). After the threshhold is done, I'd like my array A1 follow the new A2, meaning that the first 3 values of A1 should be removed.
Any tips on how to do this?
A1 = [1 4 5 8 2 2 4];
A2 = [2 5 8 15 18 24 23]
A2Thresh = A2 < 10 | A2 > 30;
A2(A2Thresh) = [ ]

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 24 Mar 2023
Edited: Dyuman Joshi on 24 Mar 2023
Use the same approach for A1 as well.
A1 = [1 4 5 8 2 2 4];
A2 = [2 5 8 15 18 24 23];
A2Thresh = A2 < 10 | A2 > 30;
A2(A2Thresh) = []
A2 = 1×4
15 18 24 23
A1(A2Thresh) = []
A1 = 1×4
8 2 2 4
Edit - This works only if both A1 and A2 have same size
  5 Comments
Axel O
Axel O on 24 Mar 2023
That did the trick! Thank you for all of your help, really appreciate it! I'll look into it more this weekend so I can avoid these issues in the future

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!