how can i plot the amplitude spectrum of these signals

22 vues (au cours des 30 derniers jours)
Samuel Molinari
Samuel Molinari le 12 Juil 2021
i need to plot the amplitude spectrum of this signals
and
g(t)=
the first fourier transform is:
and the second one is :

Réponses (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 12 Juil 2021
Fs = ... % Sampling freq
t = ... % Time
F = 0.25+cos(2*pi*50*t);
L = length(F);
N = 2^nextpow2(L);
Y = fft(F, N);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of S(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')

Scott MacKenzie
Scott MacKenzie le 12 Juil 2021
Modifié(e) : Scott MacKenzie le 12 Juil 2021
Do you want the FFT of the combination of the 20 Hz and 50 Hz signals? If so, then this might be the sort of plot you are after:
duration = 1; % seconds
sRate = 8192; % default
sInterval = 1/sRate;
% vector for values of t at each sample point
t = 0:sInterval:duration;
n = length(t); % number of samples
% build the first wave vector, as per question (20 Hz)
y1 = 0.25 + sin(2*pi * 20 * t);
% build the second wave vector, as per question (50 Hz)
y2 = cos(2*pi * 50 * t);
% combine waveforms
y = y1 + y2;
% constrain samples to +/- 1
y = rescale(y, -1, 1);
% perform fast fourier transform
Y = fft(y);
% get amplitude vs. frequency spectrum
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
tiledlayout('flow');
% plot signals
nexttile;
plot(y);
set(gca,'ylim', [-1.2 1.2]);
title('Signal');
% plot fft of signals (up to 200 Hz only)
f = sRate*(0:(n/2))/n;
nexttile;
plot(f(1:200),P1(1:200));
title('Frequency Spectrum');

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by