1 분 소요

라플라스 변환과 푸리에변환을 비교해보았다!

한동석 교수님의 5월16일 강의를 복습하다가 이 두가지를 비교해보기를 시도해보았다.

LT와 FT의 차이를 시각적으로 나타내보자!

import numpy as np
import matplotlib.pyplot as plt

# Time domain signal
t = np.linspace(0, 10, 400)
x = np.exp(-t)*np.sin(2 * np.pi * t)

# Laplace Transform
s = np.linspace(-10, 10, 400) + 1j * np.linspace(-10, 10, 400)
X_s = np.array([np.trapz(x * np.exp(-st), t) for st in s])

# Fourier Transform
omega = np.linspace(-10, 10, 400)
X_omega = np.array([np.trapz(x * np.exp(-1j * ot), t) for ot in omega])

# Plotting the time domain signal
plt.figure(figsize=(15, 10))

plt.subplot(3,1,1)
plt.plot(t, x, label='x(t)')
plt.title('Time Domain Signal')
plt.xlabel('Time (t)')
plt.ylabel('x(t)')
plt.legend()

# Plotting the Laplace Transform
plt.subplot(3,1,2)
plt.plot(s.real, np.abs(X_s), label='|X(s)|')
plt.title('Laplace Transform')
plt.xlabel('Real part of s')
plt.ylabel('|X(s)|')
plt.legend()

# Plotting the Fourier Transform
plt.subplot(3,1,3)
plt.plot(omega, np.abs(X_omega), label='|X(w)|')
plt.title('Fourier Transform')
plt.xlabel('Frequency (w)')
plt.ylabel('|X(w)|')
plt.legend()

plt.tight_layout()
plt.show()

result>

brave_MzajAk7JFl

여기서는 주어진 시간 도메인 신호 x(t)=exp(-t)sin(2pi*t)에 대한 라플라스 변환과 푸리에 변환의 차이를 시각적으로 나타내보았다.

  1. 시간 도메인 신호: 맨 위의 그래프는 원래 시간 도메인에서의 신호 x(t)를 보여준다.
  2. 라플라스 변환: 가운데 그래프는 라플라스 변환의 크기 X(s) 를 보여준다.(s는 복소수 변수)
  3. 푸리에 변환: 맨 아래 그래프는 푸리에 변환의 크기 X(w) 를 보여준다.(w는 주파수)

의의: 이러한 그래프들을 통해 각각의 변환으로 하여금 시간도메인 신호를 다른 도메인 신호로 변환하여 분석하는 방법을 시각적으로 이해해볼 수 있었다.

LT의 3D Plot을 실제로 구현해보자!

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Define the function x(t)
def x_t(t, tau):
    return np.where((t > 0) & (t < tau), 1, 0)

# Define the Laplace Transform
def X_s(s, tau):
    return (1 - np.exp(-s * tau)) / s

# Define the parameters
tau = 1
sigma = np.linspace(-1, 3, 100)
omega = np.linspace(-30, 30, 100)
sigma, omega = np.meshgrid(sigma, omega)
s = sigma + 1j * omega

# Compute the Laplace Transform
X_sigma_omega = X_s(s, tau)

# Plot the result
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection='3d')

ax.plot_surface(sigma, omega, np.abs(X_sigma_omega), cmap='viridis')

ax.set_xlabel('$\sigma$')
ax.set_ylabel('$j\omega$')
ax.set_zlabel('$|X(\sigma + j\omega)|$')

plt.show()

result>

brave_zn79dUAGty

주어진 함수 x(t)에 대한 라플라스 변환의 3D플롯을 실제로 구현해보았다.
이 플롯은 sigma와 jw의 함수로서 |X(sigma + jw)|를 보여준다.
이 시각화를 통해 시간 도메인에서 복소수 주파수 도메인으로의 변환을 이해해볼 수 있었다.

댓글남기기