Fourier Transform of a Signal

1 visualizzazione (ultimi 30 giorni)
Kutlu Yigitturk
Kutlu Yigitturk il 2 Giu 2021
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;

Risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by