Answer the question
In order to leave comments, you need to log in
How to make a generic script with fft(matlab)?
I looked for ready-made examples of using fft, but they turned out to be not at all universal, here is a good example . I edited it in Hindu so that it works for different time ranges and without hamming - I don't know how to work with filters. Frequencies less than 1Hz are not visible, but I need to detect both low and high frequencies. Frequencies less than 1Hz are detected here , but the example only works for low frequencies and generally seems like a hack. How to improve the code? What to do with the array "f"?
clear all; close all; clc;
Fs = 500;
t = 0:1/Fs:0.4-1/Fs;
s = 3*sin(2*pi*50*t) + 2*sin(2*pi*0.5*t);
plot(t, s)
f=0:length(t)/2-1;
sp=4*abs(fft(s/length(t),length(t)/2));
f=f*Fs./length(f);
it=sp(1:end);
figure; plot(f, it);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question