|
Prev: Working with state-space representation of multivariable models
Next: How can I find intervals?
From: Simon Walter on 5 May 2008 08:12 Hi I have a signal and I want to identify intervals in which the signal shows a specific characteristic (that I can define, e.g. intervals in which the signal is <1). How can I find such intervals? I want to know the length of each interval, and how many there are. Is there anyone who can explain me how to do this? Thank you!
From: Lorenzo Guerrasio on 5 May 2008 08:41 Let say your signal is S=double 1xN, you can use the sintax: A=S>1 to create a logical with 0 for values <=1 and 1es for values >1. To know how many values are above 1: sum(A). To create a vector with only these values: v=S(S>1) Hope it helps "Simon Walter" <saberhagen12(a)yahoo.de> wrote in message <fvmtmc$k73$1(a)fred.mathworks.com>... > Hi > > I have a signal and I want to identify intervals in which > the signal shows a specific characteristic (that I can > define, e.g. intervals in which the signal is <1). How can I > find such intervals? I want to know the length of each > interval, and how many there are. > > Is there anyone who can explain me how to do this? > Thank you!
From: Miroslav Balda on 5 May 2008 08:43 "Simon Walter" <saberhagen12(a)yahoo.de> wrote in message <fvmtii$dc2$1(a)fred.mathworks.com>... > Hi > > I have a signal and I want to identify intervals in which > the signal shows a specific characteristic (that I can > define, e.g. intervals in which the signal is <1). How can I > find such intervals? I want to know the length of each > interval, and how many there are. > > Is there anyone who can explain me how to do this? > Thank you! Hi The problem may be solved by a logical indexing. If x is a vector of a signal, then L=x<1; % is vector of logical values l = sum(L); % lentgth of the vector x(L), e.g. % number of values of x fulfilling the condition Hope it heps. Mira
From: Jos on 5 May 2008 09:13 "Simon Walter" <saberhagen12(a)yahoo.de> wrote in message <fvmtii$dc2$1(a)fred.mathworks.com>... > Hi > > I have a signal and I want to identify intervals in which > the signal shows a specific characteristic (that I can > define, e.g. intervals in which the signal is <1). How can I > find such intervals? I want to know the length of each > interval, and how many there are. > > Is there anyone who can explain me how to do this? > Thank you! Use logical indexing. If X represents your signal then Q = X < 1 will give you logical ones where X is smaller than 1. Then using STRFIND you can get the indices into Q where X starts and ends being smaller than 1 startind = strfind([0 Q],[0 1]) ; endind = strfind([Q 0],[1 0]) ; (ask yourself why you want to pad Q with zero?) which can be used to get the lengths. Tip: try this with a small input signal X, for instance: X = [0 0 2 2 2 0 0 2 2] ; .... so you can follow the flow. hth Jos
|
Pages: 1 Prev: Working with state-space representation of multivariable models Next: How can I find intervals? |