Detecting maximum and minimum of signal
24 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Wayne King
2013-1-9
编辑:Wayne King
2013-1-9
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 个评论
更多回答(2 个)
Jan
2013-1-9
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 个评论
Image Analyst
2013-1-9
编辑:Image Analyst
2013-1-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!