Why the fourier transform of a signal does not produce any graphing?

7 ビュー (過去 30 日間)
TEOH CHEE JIN
TEOH CHEE JIN 2022 年 12 月 8 日
コメント済み: Paul 2023 年 1 月 25 日
Hi, I have written a MATLAB code to convert the signal equations from time domain into frequency domain. However, when plotting the graph in frequency domain, there is no output as shown in the screenshot attached. Since my a(t) is a cosine, I believe there should be containing only the real part in frequency domain according to the Fourier Transform Table. Thank you.
%create symbolic functions x, a, b, c, d, e, f_c with independent variable t
syms x a h b c d e f_c f_c1 f_c2 t tau
%create symbolic functions A, B, C, D, and E with independent variable w
syms A B C D E w
x(t) = cos(100*pi*t);
a(t) = x(0.4*t);
h(t) = dirac(t-0.02);
b(t) = int(a(tau)*h(t-tau), 'tau', -inf, inf);
f_c(t) = 10*cos(2500*pi*t);
f_c1(t) = f_c(t);
f_c2(t) = f_c(t);
c(t) = b(t)*f_c1(t);
d(t) = c(t)*f_c2(t);
figure
A(w) = fourier(a(t));
subplot(2,2,1), fplot((A(w)))
xlim([-50 50]), ylim([-10 10])
title('Real part of A(\omega)')
xlabel('Frequency, \omega')
ylabel('Real A(\omega)')
grid on
B(w) = fourier(b(t));
subplot(2,2,2), fplot((B(w)))
xlim([-50 50]), ylim([-10 10])
title('Real part of B(\omega)')
xlabel('Frequency, \omega')
ylabel('Real B(\omega)')
grid on
C(w) = fourier(c(t));
subplot(2,2,3), fplot((C(w)))
xlim([-50 50]), ylim([-10 10])
title('Real part of C(\omega)')
xlabel('Frequency, \omega')
ylabel('Real C(\omega)')
grid on
D(w) = fourier(d(t));
subplot(2,2,4), fplot((D(w)))
xlim([-50 50]), ylim([-10 10])
title('Real part of D(\omega)')
xlabel('Frequency, \omega')
ylabel('Real D(\omega)')
grid on

採用された回答

Santosh Fatale
Santosh Fatale 2022 年 12 月 23 日
Hi Teoh,
The function "dirac" represents the Dirac delta function and not the Kronecker delta function. Thus, it achieves an infinity value at . The function "fplot" does not plot the infinity for the Dirac delta function, and you need to take care of that using the following workaround.
syms t
dirac_t = dirac(t);
t = -5:0.1:5;
dirac_t = dirac(t);
idx = dirac_t == Inf;
dirac_t(idx) = 1; % Assign suitable value instead of Inf.
stem(t, dirac_t); % You can even use plot function.
The modified code to plot real part of variable A is as follows:
%create symbolic functions x, a, b, c, d, e, f_c with independent variable t
syms x(t) a(t) h(t) b(t) c(t) d(t) e f_c(t) f_c1(t) f_c2(t) t tau
%create symbolic functions A, B, C, D, and E with independent variable w
syms A(w) B(w) C(w) D(w) E w
x(t) = cos(100*pi*t)
a(t) = x(0.4*t)
h(t) = dirac(t-0.02)
b(t) = int(a(tau)*h(t-tau), 'tau', -inf, inf)
f_c(t) = 10*cos(2500*pi*t);
f_c1(t) = f_c(t);
f_c2(t) = f_c(t);
c(t) = b(t)*f_c1(t);
d(t) = c(t)*f_c2(t);
figure
A(w) = fourier(a(t), w);
w = -45*pi:0.1*pi:45*pi;
subsA = A(w);
% Replace Inf value with suitable value
idx = subsA == Inf;
subsA(idx) = pi; % choose suitable value from the expression of fourier transform.
plot(w,real(subsA));
ylabel("\Re(A(\omega))");
xlabel("\omega");
xticks(-40*pi:20*pi:40*pi);
xticklabels({'-40\pi', '-20\pi', '0', '20\pi', '40\pi'})
Refer documentation of “dirac”, “fourier”, and “real” for more information and illustration examples.
  15 件のコメント
TEOH CHEE JIN
TEOH CHEE JIN 2023 年 1 月 25 日
@Paul, do you know any staff who is expert in programming filter tool?
Paul
Paul 2023 年 1 月 25 日
I do not.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by