Hi I need to write a code to plot the magnitude spectra of the following signals using MATLAB fft() function and relate the spectral lines with the constituent frequencies.
6 ビュー (過去 30 日間)
古いコメントを表示
%this is the orginal functions that i need fft()
clc ; close all ;
t = 0: .02 : 4 * pi ;
x = zeros ( size ( t ) ) ;
for k = 1 : 2 : 19
x = x + sin ( k * t ) / k ; % Square wave
end
subplot (3,1,1)
plot (t, x )
title ( ' Square wave ' )
y = zeros ( size ( t ) ) ;
for k = 1 : 19
y = y- ( -1 ) ^ k * sin ( k * t ) / k ; % Sawtooth wave
end
subplot ( 3,1,2 )
plot ( t , y )
title ( ' Sawtooth wave ' )
z = zeros ( size ( t ) ) ;
for k = 1 : 2 : 19
z = z + cos ( k * t ) / ( k * k ) ; % Triangular wave
end
subplot ( 3,1,3 )
plot ( t , z )
title ( ' Triangular wave ' )
0 件のコメント
回答 (1 件)
Pravarthana P
2022 年 12 月 1 日
Hi Yafiet Solomon,
I understand that you are trying to plot the Magnitude spectra of the signals against their corresponding frequencies.
The "fft" function computes the discrete Fourier transform (DFT) of the input signal using a fast Fourier transform (FFT) algorithm. After computing the Fourier transform of the signal, compute the vector that depicts the signal’s sampling in frequency space. Finally, plot the computed signal’s FFT with their corresponding sampling frequency.
For more information refer to the documentation links below:
Hope this information helps you.
0 件のコメント
参考
カテゴリ
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!