Fourier Transform of a Signal

2 ビュー (過去 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 Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by