Plotting a peak envelope

10 次查看(过去 30 天)
I have measured the swinging off of a resonant circuit with a oscilloscope. Now I'm trying to fit a peak envelope over this data. Therefore I've tried:
figure
plot(temp(:,1), smooth(temp(:,2),30))
hold on
plot(temp(:,1), smooth(abs(hilbert(temp(:,2))),190))
I still get a slightly oscillating function, instead of a constantly decreasing function. How can I improve the envelope function? Would really appreciate help. My solution is shown in the image. Cheers
P.s.: For the argument of smooth(x,y) I iteratively worked out optimal values

采纳的回答

Star Strider
Star Strider 2016-7-11
编辑:Star Strider 2016-7-12
I don’t have your signal, so I can’t provide definitive code.
First, do a fft of your signal so you have an idea of the frequency content.
Second, experiment with the envelope function (or its equivalent, the hilbert call you’ve already used) but without the smooth call:
y = abs(hilbert(temp(:,2)));
You may have to adjust the parameters of the hilbert function.
Another possibility is to use a bandpass filter, and just experiment with the passbands until your get the result you want. Use the results of the fft call for your design. The objective is to pass only the low-frequency envelope of the function.
-----------------------------------------------------------
EDIT
This isn’t perfect, but it’s the best I can do:
[d,s,r] = xlsread('Camill Trüeb F0002CH1.csv', 'E1:E2500');
Ts = 4E-10;
Fs = 1/Ts;
Fn = Fs/2;
tv = (0:length(d)-1)*Ts;
st = find(d > 0.1, 1, 'first');
d = d(st:end);
tv = tv(st:end);
L = length(d);
[pks, locs] = findpeaks(abs(d), tv, 'MinPeakDist',1E-7);
q = [locs' ones(size(locs'))]\log(abs(pks)); % Initial Parameter Estimaes
fitfcn = @(b,t) b(1) .* exp(b(2).*t) + b(3); % Fit Function
SSECF = @(b) sum((pks - fitfcn(b,locs')).^2); % Cost Function
[B,SSE] = fminsearch(SSECF, [pks(1); q(1); 0]);
figure(5)
plot(tv, d)
hold on
plot(tv, fitfcn(B,tv))
hold off
grid
  2 个评论
Camill Trüeb
Camill Trüeb 2016-7-12
Dear Star Strider
Thank you a thousand times! Your fitfunction approach with the cost function works way better than mine. Over all the different data sets the results are being very good. I don't think there is a perfect solution, since my measurements do have a slight offset at the first 1-2 peaks, as a result of a loading of the resonator. Again thank you very much Camill
Star Strider
Star Strider 2016-7-12
As always, my pleasure!

请先登录,再进行评论。

更多回答(2 个)

Camill Trüeb
Camill Trüeb 2016-7-11
Thank you both for the fast answers! I've now worked out the first method with findpeaks. I smooth my data, use findpeaks and fit an exponential curve on to the solutions. The solution is ok, but there is still space for improvement. @Star Strider: Unfortunately I don't have any experience with filter design and I didn't manage to change parameters of the hilbert function. When simply using abs(hilbert(data)) I don't get a good solution. I attached a set of data to this answer, maybe you could help me out with more concrete code. Thanks already!

Greg Dionne
Greg Dionne 2016-7-11
编辑:Greg Dionne 2016-7-12
If you have HILBERT then you have access to the Signal Processing Toolbox. If you have R2015b or later, try using ENVELOPE:
[d,s,r] = xlsread('F0002CH1.csv', 'E1:E2500')
%zoom in on decaying portion
envelope(d(580:end),500,'analytic')
  2 个评论
Camill Trüeb
Camill Trüeb 2016-7-12
That's what I first wanted to use. But I have 2015a as well as 2016a and none of them knows ENVELOPE. Is there a possibility this function only exists in 2015b?
Greg Dionne
Greg Dionne 2016-7-12
It should be in 16a.
cd ([matlabroot '/toolbox/signal/signal'])
edit envelope
Hopefully it'll be there.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by