Hi,
I have a excel file with raw data containg 1200 rows and 2 columns named A and B. I'm try to apply a lowpass filter on the signal but looks like its not working, hopefully someone on here may have time to guide me to the right direction.
here is what I did so far:
imported data as a table -> created a script -> inside of the script -> load rawdata.csv
% sampling frequency [Hz]
Fs = 1000;
% sampling period [s]
Ts = 1/Fs;
% time vector [s]
t = 0:Ts:3;
% Signal A
sig_A = rawdata(:,1);
% Signal A
sig_B = rawdata(:,2);
order = 4;
fcut = 8000;
[sig_A,sig_B] = butter(order,fcut/(fs/2),'low');
x = filter(sig_A,sig_B);

 채택된 답변

Alberto Mora
Alberto Mora 2021년 2월 10일
편집: Alberto Mora 2021년 2월 10일

0 개 추천

You are confusing the filter coefficient with the raw signal.
Try this:
[b,a] = butter(order,fcut/(fs/2),'low');
sig_a_filt = filter(b, a, sig_A );

댓글 수: 5

nam bui
nam bui 2021년 2월 10일
Hello, this is the updated code I have but when I plot it, there is not any output filtered appear on the figure.
% sampling frequency [Hz]
Fs = 1000;
% sampling period [s]
Ts = 1/Fs;
% time vector [s]
t = 0:Ts:3;
% Signal A , and 1 represent for first column of raw data in the excel file
sig_A = rawdata(:,1);
% Signal A , and 2 represent for first column of raw data in the excel file
sig_B = rawdata(:,2);
order = 4;
fcut = 8000;
[a,b] = butter(order,fcut/(fs/2),'low');
x = filter(a, b, sig_A);
x1 = filter(a, b, sig_B);
plot(x,x1)
Alberto Mora
Alberto Mora 2021년 2월 10일
편집: Alberto Mora 2021년 2월 10일
Please, upload also raw data.
Moreover, when you create a comment in this forum, please use the "code" section for add your code, in orther to distinguish the text to the code.
Alberto Mora
Alberto Mora 2021년 2월 10일
편집: Alberto Mora 2021년 2월 10일
Here a working example.
If this helps you, please consider to accept this post as "answer", as sign of gratitude.
Fs = 1000;
Ts = 1/Fs;% sampling period [s]
t = 0:Ts:3;% time vector [s]
sig_A = sin(3*2*pi*t)+rand(size(t))*0.1-0.05;% Signal A. I just create a noisy signal...
order = 4;
fcut = 10;
[a,b] = butter(order,fcut/(Fs/2),'low');
sig_A_filt = filter(a, b, sig_A);
figure;
plot(t, sig_A); hold on
plot(t, sig_A_filt);
legend('raw signal','filtered signal')
nam bui
nam bui 2021년 2월 10일
this is help, thank you and I'll accep this as anwser for sure
Rahim Nami
Rahim Nami 2022년 10월 13일
Hi everyone
Please, mathematical formula or mathematical model of the codes used. you insert
thank you
r_nami@gmx.com

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2021년 2월 10일

댓글:

2022년 10월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by