how can i plot the amplitude spectrum of these signals

24 次查看(过去 30 天)
i need to plot the amplitude spectrum of this signals
and
g(t)=
the first fourier transform is:
and the second one is :

回答(2 个)

Sulaymon Eshkabilov
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 2021-7-12
编辑:Scott MacKenzie 2021-7-12
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');

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by