Splitting the signal into different parts.
Ältere Kommentare anzeigen
I am trying to analyze and apply filter to a signal(measurements). But the problem is while recording the measurements, between 2 timestamps the value was not recorded, so the program used to record these measurements just connected these 2 loose ends, this is a problem for my algorithm. so i want to split the signal into multiple parts based on this abnormality. I need to do this automatically. Below is the image of the abnormality.

Below i have shown a pic of plot(diff(t)).

So my signal will now divided into 3 parts. Any idea how to do this will be appreciated.
3 Kommentare
Image Analyst
am 8 Jun. 2016
Explain why there is a second gap of 1 second along the t vector yet no such gap seems to appear when you plotted signal vs. t in the top plot. Only one time gap of 1 second seems to show up in the top plot.
Which t index, at 3500 or 7500, is the one that shows up going from t=20 to t=21 on the top plot?
JA
am 8 Jun. 2016
JA
am 8 Jun. 2016
Antworten (1)
If you have a signal like this shown in Figure2 you can use this information.
changeDetected = [false, diff(t)>0.1]; %get the points with a time step
categoryID = cumsum(changeDetected); %get the category of the time-slot (starting from 0)
nofCategorys = categoryID(end)+1; % number of found time-slots
for ii = 1:nofCategorys
mask = categoryID == (ii-1); % get a mask for the current category
extractedSignal = signal(mask); % get the signal of the current time slot
erg(ii)=yourAlgorithm(extractedSignal); % make your calculations
end
where your input data are the vetors 'signal' and 't'.
7 Kommentare
JA
am 8 Jun. 2016
goerk
am 8 Jun. 2016
The problem is that you use quotes around false. false is a boolean value and 'false' is a string.
Detailed description:
diff(t) > 0.1
The idea behind that is that you compare the discrete derivation of the time with a threshold of 0.1s. So at the points where data is missing you get a true as result the whole rest of the vector is false;
The diff command return a vector where the length is reduced by 1 in comparison with the input vector. As we want to use it as a mask for the signal we have to add an additional element to the resulting vector.
[false diff(t)>0.1]
I am not completely sure if you have to append the element at the beginning or at the end. (for the end use: [diff(t)>0.1 false]) But you can check this with
t(changeDetected)
this command should return the start time of the second and the third time slot.
JA
am 8 Jun. 2016
goerk
am 9 Jun. 2016
Then use
changeDetected = [false; diff(t)>0.1];
Note: The comma is replaced with a semicolon.
JA
am 9 Jun. 2016
JA
am 9 Jun. 2016
Kategorien
Mehr zu Digital Filtering finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!