Sampled signal spectrum ?
Afficher commentaires plus anciens
someone knows the matlab program to plot a the spectrum of a sampled signal ; example : signal x(t) ?

Réponses (1)
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!
Catégories
En savoir plus sur Spectral Measurements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

