Is it possible to define the "Fmax" on the fft function?
4 views (last 30 days)
Show older comments
Hello everyone
I am currently developing an algorithm in matlab to analyze signals from a MEMS acelerometer. Before trying to acquire the signal and do that programming i must understand how do fft and filters in matlab work. I must say beforehand that this algorithm must be as close as to normal maintenance acquisition and signal processing systems are (or at least i intend it to be).
To do that i have defined the initial variables that in that equipment i define initially to start the acquisition of the signal and processing. Those variables are the Fmax, the maximum frequency i want to see in the spectrum and with that value it defines the sampling frequency of my ADC, by obeying to the shannon theorem, and the cutting frequency of the low-pass filter i also want. I also defined the sampling time, ts, and the number of lines i want to have as resolution. (numbers are just experimental, i would appreciate if anyone would help me on that too, because as i said i want it to be an algorithm of a system to acquire and process aceleration signals of machines).
clear
clc
%% Initial Variables
Fmax=100; %maximum frequency [Hz]
Fs=2.56*Fmax; %sampling frequency as the Shannon's Theorem defines [Hz]
ts=1/Fs; %sampling time
linhas=1000; %lines number to work as resolution in the frequency spectrum
L=1000; %length of signal
t=(0:L-1)*ts; %time vector
%
I have defined 2 sinusoidal functions with 2 different frequencies. Summed them and got my "real signal".
%% Construção do Sinal a analisar
f1=sin(2*pi*15*t); %Sinal sinusoidal da 1ª frequência sin(2*pi*[Hz])
f2=sin(2*pi*51*t); %Sinal sinusoidal da 2ª frequência sin(2*pi*[Hz])
%plot dos sinais sinusoidais simples
figure(1)
subplot(3,1,1)
plot(t,f1);
title('1º Sinal Sinusoidal');
xlabel('tempo (s)');
subplot(3,1,2)
plot(t,f2);
title('2º Sinal Sinusoidal');
xlabel('tempo (s)');
%plot do sinal a analisar
sinal=f1+f2; %Sinal constituído por 2 frequências
subplot(3,1,3)
plot(t,sinal);
title('Sinal Complexo');
xlabel('tempo (s)');
Next i did the spectral analysis of "sinal" just like this:
%% Spectral Analysis
NFFT=2^nextpow2(linhas);
RBW=Fs/2*linspace(0,1,NFFT/2+1);
F=fft(sinal,NFFT)/L;
figure(4)
subplot(1,1,1)
plot(RBW,2*abs(F(1:NFFT/2+1)));
title('Espetro de Frequências')
xlabel('Frequência(Hz)')
ylabel('Amplitude')
I know it misses the filter, but i'm adding complexity at slow rate. Like it is i obtain the correct frequencies and amplitude of the signal but i want the plot to adjust the x-axis to the Fmax i defined but i'm not seeing how, and if the resolution i want is working. Perhaps i'm asking too many questions but i want help as i'm no matlab or signal processing expertise.
5 Comments
Star Strider
on 4 Feb 2020
‘So you're saying that an anti-aliasing filter for what i want, it's useless if implemented via software?’
Yes. If the anti-aliasing filter is not implemented in hardware at the input of the ADC, the aliased frequencies will already be present in the sampled signal, and are then impossible to remove.
Once you have tha anti-aliased sampled signal, you can do whatever you want with it. There is always a good argument to be made for using the highest sampling frequency possible (1 kHz is standard) in order to provide the best time and frequency resolution.
My pleasure!
Answers (0)
See Also
Categories
Find more on Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!