Have one array follow another array with a threshhold
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Axel O
am 24 Mär. 2023
Kommentiert: Axel O
am 24 Mär. 2023
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) = [ ]
0 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 24 Mär. 2023
Bearbeitet: Dyuman Joshi
am 24 Mär. 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) = []
A1(A2Thresh) = []
Edit - This works only if both A1 and A2 have same size
5 Kommentare
Dyuman Joshi
am 24 Mär. 2023
Bearbeitet: Dyuman Joshi
am 24 Mär. 2023
When you perform this operation
FLWAll(FLWTHRESH) = [];
The number of elements of FLWALL are reduced, and you can not delete the indices who are greater are the number of elements of FLWALL, which the logical vector VTHRESH might contain.
Thus the error "Matrix index is out of range for deletion".
To resolve the issue, combine the both the conditions together and perform the deletion -
VTHRESH = VAll < 18.69;
VAll(VTHRESH) = [];
FLWTHRESH = FLWAll < 0.10 | FLWAll > 0.30;
FLWAll(FLWTHRESH | VTHRESH) = [];
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!