Detecting maximum and minimum of signal
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey guys,
I'd like to write some code which finds the mean stress and stress amplitude for each block of a signal whose amplitude changes from one constant value to another (pictured below).
In order to do this, I need the maximum and minimum values for each block of the signal. The only problem is that my program should be able to read any signal with multiple blocks of constant amplitude so the method needs to be general and not just for the example below.
Any help would be greatly appreciated :)
0 comentarios
Respuesta aceptada
Wayne King
el 9 de En. de 2013
Editada: Wayne King
el 9 de En. de 2013
One thing you can do is to use the Hilbert transform to form the analytic signal corresponding to your signal, then use the modulus (absolute value) of the analytic signal to detect changes in the mean.
For a purely sinuisodal signal obviously the modulus of the analytic signal is a constant. Given numerical precision concerns and the fact that the measurement will contain random noise, the modulus in a given block will not be a constant, but from your example above, it will be close.
For example:
n = 0:399;
x = zeros(400,1);
x(1:159) = cos(pi/4*n(1:159));
x(200:end) = 1/5*cos(pi/2*n(200:end));
plot(n,x)
Now, use hilbert() to obtain the analytic signal
y = hilbert(x);
plot(abs(y))
Notice how the modulus of the analytic signal captures changes in the mean.
If you do something like:
changepoints = abs(diff(abs(y)));
plot(changepoints)
You can see where the mean levels are changing. You will have to ignore the very beginning and end of the interval.
Of course there are a number of change point detection algorithms out there better than the technique I've given (detecting a change based on the first difference of the absolute value of the analytic signal), so feel free to use another technique, but hopefully that gets you started.
0 comentarios
Más respuestas (2)
Jan
el 9 de En. de 2013
Start with finding the local extrema, e.g. by:
- http://www.mathworks.com/matlabcentral/fileexchange/30490-1d-non-derivative-peak-finder
- http://www.mathworks.com/matlabcentral/fileexchange/33555-find-zeros-local-maximums-loacal-minimums
- http://www.mathworks.com/matlabcentral/fileexchange/26581-peakseek
- ... search in the FileExchange for more
Then locating the blocks should be easy, when you can define a threshold value to identify a switch.
0 comentarios
Image Analyst
el 9 de En. de 2013
Editada: Image Analyst
el 9 de En. de 2013
How about:
minValue = min(theBlock(:));
maxValue = max(theBlock(:));
You only asked about finding the min and max value. You didn't ask about locating the blocks themselves, so presumably you already have a way of doing that. If not, I posted a method for that about a month or two ago involving conv() and thresholding I think.
You said your " program should be able to read any signal". I'm not sure what this means, but perhaps you need to get the Data Acquisition Toolbox if you need to read from an instrument, or perhaps fread(), dlmread(), importdata() or something like that if you need to read it from a file. If you have some other definition of read, let's hear it.
0 comentarios
Ver también
Categorías
Más información sobre Transforms 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!