필터 지우기
필터 지우기

how can i plot the amplitude spectrum centered at the zeroth frequency.

조회 수: 3 (최근 30일)
Batuhan Samet Demirci
Batuhan Samet Demirci 2022년 4월 23일
댓글: Paul 2023년 10월 11일
Hi. I have fft of vector and i wanna know how can i plot the amplitude spectrum centered at the zeroth frequency.
I attached the file which i load to matlab.
I wrote this below. And i wanna plot its amplitude spec at zeroth freq.
"
load data.mat
X= fft(x)
"

답변 (1개)

Nithin
Nithin 2023년 10월 11일
Hi Batuhan,
I understand that you have a FFT of vector and want to know the process of plotting the amplitude spectrum centered at the zeroth frequency.
To implement this, kindly refer to the following steps -
1. Obtain your signal in the time domain.
2. Compute the Fourier Transform of the signal using the "fft" function.
X = fft(x); % Assuming your signal is stored in a variable 'x'
3. Shift the zero frequency component to the center of the spectrum using "fftshift" function.
X = fftshift(X);
4. Compute the amplitude spectrum by taking the absolute value of the shifted spectrum.
amplitude_spectrum = abs(X);
5. Create a frequency vector that corresponds to the frequency components of the spectrum. Use the "linspace" function to create a linearly spaced frequency vector.
N = length(x);
fs = 1; % Assuming a sampling frequency of 1 Hz
frequencies = linspace(-fs/2, fs/2, N);
6. Plot the amplitude spectrum centered at the zeroth frequency.
plot(frequencies, amplitude_spectrum);
xlabel('Frequency (Hz)');
ylabel('Amplitude');
title('Amplitude Spectrum Centered at Zero Frequency');
For more information regarding "fft" and "fftshift" functions, kindly refer to the following documentation:
I hope this answer resolves your query.
Regards,
Nithin Kumar.
  댓글 수: 1
Paul
Paul 2023년 10월 11일
Hi Nithin,
The expression for "frequencies" is not correct. See this Question for more discussion.

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

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by