Fitting Envelope Peak Curves?
21 views (last 30 days)
Show older comments
Hello,
I've been trying to take the peak envelope of a signal that I have, and I am able to get the upper and lower peak envelopes. However, the spacing with the peaks either causes the peaks to overlap (sometimes, the lower peak envelop curve will be higher than the upper) or for the curves not to be smooth. I have attached an image of what I'd like for the peaks to end up like and an image of what I actually got. :(
The first picture is what I got through this code. I want more of a hump shape a little bit like the picture on the very bottom. Basically if I got the same code, without the overlap my problem would be solved. The data is attached in a .zip folder.
f = xlsread('d2.csv');
%plotting the signal
t = f(:,1);
X1 = f(:,2);
%Some of the envelope code was not working properly because MATLAB read
%some lines of the excel file as infinite numbers. The envelope function
%does not take infinite numbers.
%Thus, the below code deletes the infinite numbers from the array. There
%are only 2 of them.
fin = isfinite(X1);
t = t(fin);
X1 = X1(fin);
X = X1;
% X = bandpass(X1, [50 185], 25000);
% Y = fft(X);
% y = hilbert(X);
figure;
[up, lo] = envelope(X,75800, 'peak');
plot(t,up,'r');
hold on
plot(t,X, 'b');
plot(t,lo,'k');
% plot(t,real(Y),'y');
% plot(t,imag(Y),'m');
hold off
f = xlsread('d2-2.csv');
%plotting the signal
t = f(:,1);
X1 = f(:,2);
%Some of the envelope code was not working properly because MATLAB read
%some lines of the excel file as infinite numbers. The envelope function
%does not take infinite numbers.
%Thus, the below code deletes the infinite numbers from the array. There
%are only 2 of them.
fin = isfinite(X1);
t = t(fin);
X1 = X1(fin);
X = X1;
% X = bandpass(X1, [50 185], 25000);
% Y = fft(X);
% y = hilbert(X);
figure;
[up, lo] = envelope(X,75800, 'peak');
plot(t,up,'r');
hold on
plot(t,X, 'b');
plot(t,lo,'k');
% plot(t,real(Y),'y');
% plot(t,imag(Y),'m');
hold off
3 Comments
Greg Dionne
on 9 Jul 2018
You can adjust the sensitivity of the 'peak' variant.
[up, lo] = envelope(X,5000, 'peak');
Alternatively you could try the 'rms' variant after subtracting (and restoring) the mean.
A lot depends on what you want to do with the envelope when you're done with it.
Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!