MATLAB: Filtering a very noisy signal

signal filtering

Hi everyone
I´m trying to filter a very noisy signal.
My problem is I need some help because I don´t know how to do it.
My signal looks like this
As anyone can see this is very noisy. I want to filter this signal so that I can get a signal that follows the top values. To understand it better this I am measuring the temperature on a conveyor belt which transports something (which corresponds to the lower temperatures). I am interested just in the temperatures of the C.Belt…
I want that my signal should look like this.
can someone help me? This is my data in a matfile Thanks in advance

Best Answer

Try the following code. Fistly, by the help of psd function, I observed your data's frequency plot to see at what frequencies you have noise, then in second part, by using butterworth function, I designed a filter to smooth your data. Hope this helps. Note that fc cut off frequency and order of filter should be chosen wisely.
load('oven.mat');
A=meas.Temp;
t=meas.Time;
Fs=1000;
h1=spectrum.welch;
set(h1,'Windowname','Hann');
set(h1,'OverlapPercent',66.7);
set(h1,'SegmentLength',1024);
myPsd=psd(h1,A,'Fs',Fs);
figure(1);
semilogx(myPsd.Frequencies/(2*pi),myPsd.Data);
set(gca,'XLim',[3 100]);
%it is seen that your data contains noise higher than 50Hz
fc=30;%cutoff frequency(Hz)
fs=1000;%sampling frequency(assumed)
[b,a] = butter(5,fc/(fs/2),'low');
y=filter(b,a,A);
figure(2);
plot(t,A);hold on;plot(t,y);legend('original','filtered');
hold off;