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

1 visualización (últimos 30 días)
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?

Respuesta aceptada

KSSV
KSSV el 3 de Mayo de 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

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by