How to find the upper and the lower curves of a noisy data

5 views (last 30 days)
Hi.
With the attached data, I'm doing plot(Scope,Temperature) Then, I'm trying to find the curves of the upper and the lower boundaries of this noisy data (so I wouldn't see the middle part). In other words, I want to do what's shown in the jpg file. I've tried the findpeaks command to find the upper boundary, but it is still resulting in a similar curve. I've also tried using some of the Matlab command files that others have posted, but they are not working for me (it is very likely that I'm not using them correctly). Could anyone possibly tell me how to do this? I'm very new to Matlab and learned about plotting about a week ago, so detailed instructions will be greatly appreciated.
Thank you so much for your time.

Accepted Answer

Star Strider
Star Strider on 13 Oct 2014
Edited: Star Strider on 13 Oct 2014
Your curves are actually a modulation envelope with your ‘Temperature’ signal modulating a 1 Hz ‘carrier’ that has rich harmonics every 1 Hz. So you actually have only one curve.
My analysis of your signal:
D = matfile('Trial.mat');
Sc = D.Scope;
Tp = D.Temperature;
figure(1)
plot(Sc, Tp) % Plot Raw Signal
grid
title('Raw Signal')
xlabel('Scope')
ylabel('Temperature')
FTp = fft(Tp)/length(Tp); % FFT Calculations
Ts = mean(diff(Sc));
Fs = 1/Ts;
Fn = Fs/2;
Fv = linspace(0,1,length(Tp)/2+1)*Fn;
Iv = 1:length(Fv);
figure(2) % Plot FFT
semilogy(Fv, abs(FTp(Iv)))
grid
axis([0 10 1E-4 1E+2])
title('Fourier Series of Raw Signal')
xlabel('Frequency (Hz)')
ylabel('Amplitude')
[n,Wn] = buttord(0.1/Fn, 0.15/Fn, 1, 10); % Design Filter
[z,p,k] = butter(n,Wn);
[sos,g] = zp2sos(z,p,k);
Tpf = filtfilt(sos,g,Tp); % Filtered Data
figure(3) % Plot Filtered Data
plot(Sc, Tpf)
grid
title('Filtered Temperature Signal')
xlabel('Scope')
ylabel('Temperature')
producing:
The signal that the plot represents is ‘Tpf’, your lowpass-filtered ‘Temperature’ signal.
  2 Comments
dj
dj on 13 Oct 2014
Ok, I'll be honest.
I know that you used the Butterworth filter, but I'm just amazed by how you filtered it after analyzing the frequency. It seems like Matlab is capable of doing so many amazing things as long as you know how to use it. Thank you so much! I just can't thank you enough! I've been trying to find the peaks to plot for about 2 days now, and what you've done is even better.
Just wondering, do you have a recommendation on what to do if I want to use Matlab as well as you can? Did you refer to any books for signal analysis? You're just amazing. Thank you once again!
Star Strider
Star Strider on 13 Oct 2014
My pleasure! I very much appreciate your compliments!
The filter design relied on the fundamental ‘carrier’ frequency being 1 Hz. I could have designed the passband and stopband frequencies to be up to about 0.9 Hz. My choice of 0.1 and 0.15 Hz were convenient, since I didn’t see much above those frequencies.
Most of what I did here involved signal processing, so depending on what you are researching, I would concentrate on that, and when you have time, statistics to help you interpret your results (and the literature). There are a lot of books and other information on myriad subjects that also involve MATLAB in the Academia section, and particularly the Student section. Click through on those and explore them, including Books and Hardware Support. (It turns out that MATLAB can do a lot without the Instrument Control or Data Acquisition Toolboxes. The supporting software is free and it integrates seamlessly with the rest of MATLAB.) I would also check out the Blogs (link at the top of this page).
As far as using MATLAB, a lot of what I did here is simply experience. It was fairly straightforward for me here, but underlying that were a couple decades of sometimes frustrating experimentation while I figured out how to approach problems that in retrospect seemed facepalm-obvious!
As far as research goes, you need to understand your study design, your instrumentation, and the nature of your data, so take time to write out what you are going to do and how you are going to do it. Go to the literature to see how others have approached your problem and what they found. My one bit of advise w.r.t data analysis is to begin simply — here taking the FFT to analyse the data (because I recognised the modulation envelope) — and let the analysis guide you in the direction that seems most logical. There is no magic approach, since every problem has its own unique characteristics.
Again, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!