Plotting frequency spectrum of signal
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi everyone, here I am just trying to plot a one-sided frequency spectrum, but my graph doesn't appear to look right corresponding to the signal. Am I doing something wrong?
My plot is posted below as well as my code:
close all;
clear all;
N = 8;
n = 0:N-1; % numbering the samples
xn=3+5*sin(2*pi*4000*n/N)+2*sin(2*pi*6000*n/N);
MFx = abs(fft(xn));
plot(n(1:N/2),MFx(1:N/2)) % plot posi
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149895/image.png)
tive frequencies xlabel('Frequency (Bins)') ylabel('Magnitude'); title('Single-sided Magnitude spectrum (bins)');
댓글 수: 0
답변 (1개)
Star Strider
2015년 5월 7일
Your code is correct. Experiment with larger values of ‘N’, perhaps N=64.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!