Creating Low Pass Filter for Time vs. Volts

I have a data set of time vs. volt obtained using an ossiliscope.
This data was imported to matlab and columns were extracted and the signal was plotted:
raw_time = raw_data(:,1);
voltage = raw_data(:,2);
plot(raw_time,voltage)
It then had to be normalized:
newtimeraw = ((raw_time - min(raw_time))/(max(raw_time)-min(raw_time)))*6;
The normalized signal was plotted:
plot(newtimeraw,voltage)
I am trying to create a low pass filter for the normalized signal and then apply a fourier transform. This is the code I have but I am genuinely lost, and am almost positive most of this code is incorrect in one way or another.
syms a b
fc = 1
fs = length(newtimeraw)/(max(newtimeraw)-min(newtimeraw))
signal = [newtimeraw,voltage]
[b,a] = butter(2,(fc/(fs/2)), 'low')
filtered_signal = filter(b,a,signal)
figure
freqz(b,a)
figure
subplot(2,1,1)
plot(newtimeraw,voltage)
subplot(2,1,2)
plot(newtimeraw,filtered_signal)
F_sig = 2*abs(fft(raw_data))/length(raw_data);
F_Fsig = 2 *abs(fft(filtered_signal))/length(filtered_signal);
freqVector = linspace(0, fs/2, length(filtered_signal/2+1));
figure
semilogx(freqVector,F_Fsig(1:end/2)+1)

2 Comments

Two observations:
1) Do not use the Symbolic Math Toolbox for this!
2) a second-order Butterworth lowpass filter is not going to do much to filter your signal.
Why are you trying to filter time i.e newtimeraw in the line 6 ? Aren't you trying to filter the voltage?

Sign in to comment.

Answers (0)

Asked:

on 7 Dec 2019

Commented:

on 10 Dec 2019

Community Treasure Hunt

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

Start Hunting!