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

1 次查看(过去 30 天)
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?

采纳的回答

KSSV
KSSV 2021-5-3
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by