Sampled signal spectrum ?

5 ビュー (過去 30 日間)
nabil noble
nabil noble 2021 年 1 月 6 日
回答済み: Suraj Kumar 2025 年 4 月 2 日
someone knows the matlab program to plot a the spectrum of a sampled signal ; example : signal x(t) ?

回答 (1 件)

Suraj Kumar
Suraj Kumar 2025 年 4 月 2 日
Hi Nabil,
To plot the spectrum of a sampled signal in MATLAB, we can use the Fast Fourier Transform (FFT) to convert the time-domain signal into its frequency-domain representation.To learn more about 'fft' function in MATLAB, please refer to the following documentation link: https://www.mathworks.com/help/matlab/ref/fft.html
We can compute the two-sided spectrum and convert it to a single-sided spectrum to get the amplitude of the frequency components. We can define the frequency domain (`f`) for plotting and then visualize the single-sided amplitude spectrum. This will allow us to see the dominant frequencies present in the signal.
You can refer to the attached code snippet for better understanding:
Fs = 400;
T = 1/Fs;
L = 1000;
t = (0:L-1)*T;
f1 = 100;
f2 = 200;
x = 0.5+ cos(2*pi*f1*t) + 2*cos(2*pi*f2*t);
figure;
plot(t, x);
title('Time-Domain Signal');
xlabel('Time (s)');
ylabel('Amplitude');
X = fft(x);
P2 = abs(X/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure;
plot(f, P1);
title('Single-Sided Amplitude Spectrum of x(t)');
xlabel('Frequency (Hz)');
ylabel('|P1(f)|');
Happy Coding!

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by