Accelerometer data to obtain tremor frequency
Mostra commenti meno recenti
Hi all,
I have tri-axial accelerometer data which has 6 channels. the first 3 are XYZ of right and next 3 are XYZ of left. I want to know the tremor frequency from this. this has been sample at Fs=333. what steps should i do to get my output in frequency domain. kindly help me out as im very new to MATLAB.
Thanks in advance!
Attached is the tremor file obtained
1 Commento
Paras Shaikh
il 13 Set 2022
If anyone of u know about this error? As i cant find my algorithm name in this model.h Continuosly finding this error
Risposte (1)
triax = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/587501/anj%20off%20rt.txt');
Fs = 333;
nsamp = size(triax,1);
time = (0:nsamp-1) / Fs;
first_half = 1:ceil(nsamp/2);
nhalf = length(first_half)
freqs = linspace(0, Fs/2, nhalf);
XL = triax(:,1);
XL_fft = fft(XL - mean(XL));
subplot(2,1,1);
plot(time, XL); xlabel('s'); ylabel('mag')
subplot(2,1,2);
plot(freqs, abs(XL_fft(first_half))); xlabel('Hz'); ylabel('mag');
I do not promise that the frequencies are correct. Read the first example of the documentation for fft() to see how to create the frequencies.
12 Commenti
Hashvi Sai
il 18 Apr 2021
Paras Shaikh
il 11 Set 2022
Hey . I have used this fft code. Worked well . Can u plz mention about filtering of obtained frequency. Waiting for reply
Walter Roberson
il 12 Set 2022
Sorry, I do not have any experience with filtering the frequencies in this context.
@Star Strider has far more filtering experience than I do.
Star Strider
il 12 Set 2022
@Paras Shaikh — What do you want to filter? What version of MATLAB do you have? Do you have the Signal Processing Toolbox?
@Walter Roberson — Thank you!
Paras Shaikh
il 12 Set 2022
I have matlab 2016a I want to filter out my imu data(acc+gyro) But i dont know.. i have to filter my data before apply fft or after. Actually i have no idea about it.. its the part of my project . So how to do?
Star Strider
il 12 Set 2022
Modificato: Star Strider
il 12 Set 2022
This uses the existing data to present and filter the highest peak (about 7.5 Hz) as well as filter out the D-C offset.
A prototype bandpass filter that should work in R2016a would be implemented as described here —
Data = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/587501/anj%20off%20rt.txt')
Fs = 333; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
NrSp = size(Data,2); % Number Of Subplots
L = size(Data,1); % Length Of Data Vectors
t = linspace(0, L-1, L)/Fs; % Time Vector
NFFT = 2^nextpow2(L); % For Efficiency
FTData = fft(Data - mean(Data),NFFT)/L; % Fopurier Transform
Fv = linspace(0, 1, NFFT/2-1)*Fn; % Frequency Vector (For Plots)
Iv = 1:numel(Fv); % Index Vector (For Plots)
figure
sp = [1:2:NrSp 2:2:NrSp]; % Order 'subplot' Plots
for k = 1:NrSp
subplot(3,2,sp(k))
plot(Fv, abs(FTData(Iv,k))*2) % Plot Fourier Transforms
grid
xlabel('Frequency')
ylabel('Magnitude')
xlim([0 50])
% xlim([5 10])
title(sprintf('Column %d',k))
end
sgtitle('Fourier Transform of Data')
figure
sp = [1:2:NrSp 2:2:NrSp];
for k = 1:NrSp
subplot(3,2,sp(k))
plot(t, Data(:,k))
grid
ylim([20 60])
xlabel('Time')
ylabel('Amplitude')
title(sprintf('Column %d',k))
end
sgtitle('Original Time-Domain Data')
Wp = [7.25 7.75]/Fn; % Define Passband In Hz, Normalise To (0,pi)
Ws = Wp.*[0.95 1.05]; % Stopband (Normalised)
Rs = 50; % Stopband Ripple (Attenuation) dB
Rp = 1; % Passband Ripple dB
[n,Wn] = ellipord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp); % Design Filter
[sos,g] = zp2sos(z,p,k); % Implement Filter As Second-Order-Section Representation
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 15])
set(subplot(2,1,2), 'XLim',[0 15])
Data_Filt = filtfilt(sos,g,Data);
figure
for k = 1:NrSp
subplot(3,2,sp(k))
plot(t, Data_Filt(:,k))
grid
ylim([-10 10])
xlabel('Time')
ylabel('Amplitude')
title(sprintf('Column %d',k))
end
sgtitle('Time-Domain Plots of Bandpass (7.25-7.75 Hz) Filtered Data')
Make appropriate changes to the code and filter characteristics to work with your data.
EDIT — Minor appearance tweaks.
.
Walter Roberson
il 12 Set 2022
What do you want the filtering to accomplish ?
Is your X Y Z acceleration data or is it position data? Your use of fft() on the row data implies that it is position data.
Paras Shaikh
il 13 Set 2022
Hey this is my data
Paras Shaikh
il 13 Set 2022
I have applied fft on accelerometer data (xyz)
Star Strider
il 13 Set 2022
@Paras Shaikh — Post this as a new question, along with what you want to do.
Post a link to it here.
Paras Shaikh
il 13 Set 2022
Star srider if u can do this coding to my data.. that will be great help.. ok im trying to post
Paras Shaikh
il 13 Set 2022
Modificato: Walter Roberson
il 13 Set 2022
Categorie
Scopri di più su Digital and Analog Filters in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




