Filter löschen
Filter löschen

Extracting sequential values from a matrix taking into account two filter criteria

2 Ansichten (letzte 30 Tage)
Dear Community,
from the provided Matrix I would like to extract a Data Package. If the value in row 2 of the Matrix exceeds the Symbol Threshold for the first time AND row 1 above shows a "1" , the Data Package begins. The Data Package ends when the value of row 2 exceeds the Symbol Threshold a second time AND the value above in row 1 again shows a "1". All values in between belong in the Data Package.
Symbol_Thres =
77.3500
Matrix =
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
83 5 80 36 21 80 12 31 12 31 91 43 32 91 83 23
The Result should look like this:
Data_Package =
1 0 1 0 1 0 1 0 1
80 12 31 12 31 12 43 32 91
May you help me with this?

Akzeptierte Antwort

KSSV
KSSV am 3 Mai 2021
Symbol_Thres = 77.3500 ;
Matrix = [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
83 5 80 36 21 80 12 31 12 31 91 43 32 91 83 23] ;
idx = (Matrix(1,:)==1) & (Matrix(2,:)>Symbol_Thres) ;
id0 = find(idx) ;
iwant = Matrix(:,id0(1):id0(2))
iwant = 2×9
1 0 1 0 1 0 1 0 1 80 12 31 12 31 91 43 32 91

Weitere Antworten (0)

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!

Translated by