how can i plot the amplitude spectrum of these signals
23 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i need to plot the amplitude spectrum of this signals
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682248/image.png)
and
g(t)=![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682253/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682253/image.png)
the first fourier transform is: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682258/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682258/image.png)
and the second one is : ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682263/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682263/image.png)
0 Commenti
Risposte (2)
Sulaymon Eshkabilov
il 12 Lug 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)|')
0 Commenti
Scott MacKenzie
il 12 Lug 2021
Modificato: Scott MacKenzie
il 12 Lug 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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/682413/image.jpeg)
0 Commenti
Vedere anche
Categorie
Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!