how do i know which filter should i use?

조회 수: 8 (최근 30일)
Sheraz Khan
Sheraz Khan 2018년 10월 19일
댓글: Star Strider 2018년 10월 20일
Hi guys, I have been working on a smartphone sensor and I have the data. it consists of time acceleration in x y z-direction. so i tried to plot the time history of all three in one graph and guess what, it comes up EMPTY. can anybody clear this issue for me? secondly, when I run FFT for the data it shows a lot of peaks(it should be showing a few peaks right?) I know there is noise in the signal but then I don't know which filter to use. how am I suppose t know which kind of filter is suitable for which condition. and how am I suppose to remove the peaks now.. I
have attached the data file (the data i used is till row 3767). i used the following code,,
%%Import data from text file.
% Script for importing data from the following text file:
%
% F:\Masters BUW\MASTER ARBEIT\Sensor Simulation\Data\SM-G950F_samsung_dreamltexx.csv
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.
% Auto-generated by MATLAB on 2018/10/19 00:51:50
%%Initialize variables.
filename = 'F:\Masters BUW\MASTER ARBEIT\Sensor Simulation\Data\SM-G950F_samsung_dreamltexx.csv';
delimiter = ' ';
startRow = 23;
endRow = 3767;
%%Format for each line of text:
% column1: double (%f)
% column2: double (%f)
% column3: double (%f)
% column4: double (%f)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%f%f%f%f%*s%*s%[^\n\r]';
%%Open the text file.
fileID = fopen(filename,'r');
%%Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, endRow-startRow+1, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'TextType', 'string', 'EmptyValue', NaN, 'HeaderLines', startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
%%Close the text file.
fclose(fileID);
%%Post processing for unimportable data.
% No unimportable data rules were applied during the import, so no post
% processing code is included. To generate code which works for
% unimportable data, select unimportable cells in a file and regenerate the
% script.
%%Allocate imported array to column variable names
tim = dataArray{:, 1};
x = dataArray{:, 2};
y = dataArray{:, 3};
z = dataArray{:, 4};
%%Clear temporary variables
clearvars filename delimiter startRow endRow formatSpec fileID dataArray ans;
%%mydata
t=tim-3.103056357614000e+03;
accx=detrend(x, 'constant');
accy=detrend(y, 'constant');
accz=detrend(z, 'constant');
X= [accx, accy, accz];
%
for i = 1:1:3
subplot(3,1,i)
plot(t,X(i))
end
Fs= 50;
T= 1/Fs;
L=3745;
time= (1:L-1)*T;
accxx= detrend(accx);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(accxx,NFFT,1);
f = Fs/2*linspace(0,1,NFFT/2);
% Plot single-sided amplitude spectrum.
figure
plot(f,abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
  댓글 수: 3
Rik
Rik 2018년 10월 20일
Today I formatted your code, next time, use the {}Code button. See here for a GIF showing how to do it.
Star Strider
Star Strider 2018년 10월 20일
If you have broadband noise (as it appears you do), a frequency-selective filter will not produce the results you want.
I would use the Wavelet Toolbox (link) functions instead.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by