Get spectrum. Fourier Transform
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello! I need to get Fourier spectrum. I think, I am close to the goal, but have some misunderstandings. Variable 'signal' contains the array of input data (50006 points), step of measure is 0.1, so I have a signal in physical space (signal(time)) and attempt to achieve the same in Fourier space (FourierTransform(frequency)).
Here is my try:
%%discretisation in physical space
step_time=0.1;
T=step_time*length(signal); % the whole time of measurements
time_=0.1:step_time:T; % according to Nyquist theorem
%%disret. in Fourier space
f_step=1/T;
F_duration = 1/step_time;
f_frequency = 0: f_step: F_duration;
f_frequency(end) = [];
%%get spectrum and get it normalized
Fourier_trans = fft(signal);
N_=length(Fourier_trans);
a=(Fourier_trans.*conj(Fourier_trans))/N_; % amplitude and normalization
but it goes wrong. What did I do incorrect..? Probably in last lines? Thank you in advance!
댓글 수: 0
답변 (1개)
Star Strider
2017년 3월 14일
See if this works:
step_time=0.1;
sampling_frequency = 1/step_time;
nyquist_frequency = sampling_frequency/2;
%%get spectrum and get it normalized
Fourier_trans = fft(signal);
N_ = length(Fourier_trans);
a = abs(Fourier_trans)/N_; % amplitude and normalization
frequency_vector = linspace(0, 1, fix(N_/2)+1)*nyquist_frequency;
idx_vct = 1:length(frequency_vector);
figure(1)
plot(frequency_vector, a(idx_vct)*2)
grid
Note — This is UNTESTED CODE. It should work.
댓글 수: 5
Star Strider
2017년 3월 15일
My pleasure.
This assignment:
a = (Fourier_trans.*conj(Fourier_trans))
calculates power (the square of amplitude), so you would have to divide by ‘N_^2’ to normalise it correctly.
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!