Fourier Transform Step function

6 Ansichten (letzte 30 Tage)
Daniel Sartison
Daniel Sartison am 6 Nov. 2018
Hallo,
i have a bit of a problem, cause I need to get the frequency spectrum of this function:
f(t) = 3,97/2*(1-cos(pi*t/tr))
f(t<0) = 0
f(t>tr) = 3,97
tr = 0.8*10^-6
I tried to do it and my result looks like this:
Here is the code I used:
fa = 10^8; % Abtastfrequenz
fn = fa/2; % Nyquistfrequenz
N = 1024^2; % gewünschte FFT-Länge (N=2^x, sonst wird der DFT-Algorithmus verwendet!)
df = fa/N; % Frequenzauflösung
t = 0 : 1/fa : (N-1)/fa;
tr = 0.8*10^(-6);
f = 3.97/2*(1-cos(pi*t/tr));
f(t>tr) = 3.97;
f(t<0) = 0;
a1 = 3.97;
y = f; % y-Vektor
y = [y(1:N/2) zeros(1, N/2)];
max_y = max(abs(y))*1.1;
H = fft(y, N);
amplH = abs(H);
x_fn = 0 : df : fn-df;
x_fa = 0 : df : fa-df;
amplitudengang = [amplH(1)/N amplH(2:N/2)/(N/2)];
figure;
plot(x_fn, 20*log10(amplitudengang))
axis([0 fn -100 20*log10(a)+3])
set(gca,'XScale','log')
title('Amplitudengang')
ylabel('Amplitude in dB')
xlabel('Frequenz [Hz]')%['Auflösung: ',num2str(df),' Hz Frequenz in Hz'])
grid
To be honest I got most of the code out of the internet but it worked perfectely for my impuls function.
Thank you.
Regards, Daniel

Antworten (0)

Kategorien

Mehr zu Digital and Analog Filters finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by