Fourier Transform of a Signal
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Inspired by the codes written by Sulaymon Eshkabilov, I created such a code block. But I can't get an output like below, where could the error be?
clear all
close all
clc
t = 0 : 0.001 : 2;
x = exp(-t).*(cos(10*t) + cos(30*t)).*unit(t);
L = numel(x);
Y = fft(x);
M2 = abs(Y/L);
M1 = M2(1:L/2+1);
M1(2:end-1) = 2*M1(2:end-1);
dt=.001;
Fs = 1/dt;
f = Fs*(0:(L/2))/L;
subplot(2,1,1)
plot(t,x)
grid
title({'2exp(-4t)sin(10t)heaviside(t)'})
xlabel('Time (sec)')
ylabel('(x)t')
subplot(212)
plot(f, abs(M1))
xlim([0, 50])
ylim([0, 0.4])
grid on
title({'Amplitude Spectrum'})
xlabel('Frequency (rad/sec)')
ylabel('|X(w)|')
function y = unit(x)
y = zeros(size(x));
y(x>=0) = 1;
end
Desired output;
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Discrete Fourier and Cosine Transforms 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!