Fourier Transform of a Signal

조회 수: 1 (최근 30일)
Kutlu Yigitturk
Kutlu Yigitturk 2021년 6월 2일
편집: Kutlu Yigitturk 2021년 6월 2일
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개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by