0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Z 変換とサイン波

Posted at

1. アナログ系の基礎式

微分演算子 $s$ を離散時間に変換するのが基本。

dx/dt ↔ sX(s)

これを $z$ 領域に変換する近似が差分法や双一次変換です。


2. 差分近似と Z 変換

サンプリング周期を $T$ とすると:

  • 前進差分法 (Forward Difference)
s ≈ (z - 1) / T
  • 後退差分法 (Backward Difference)
s ≈ (1 - z^-1) / T
  • 双一次変換 (Bilinear Transform, Tustin法)
s ≈ (2/T) * (1 - z^-1) / (1 + z^-1)

👉 これらを使ってアナログフィルタ H(s) を H(z) に変換できる。


3. 入力サイン波

入力信号:

x[n] = sin(ω0 nT)

サンプリング周期 T で離散化したサイン波。


4. デジタルフィルタ設計例

アナログ一次ローパスフィルタ:

H(s) = 1 / (s + 1)

各手法で $s$ を置き換えると:

  • 前進差分:
H(z) = 1 / ( (z-1)/T + 1 )
  • 後退差分:
H(z) = 1 / ( (1 - z^-1)/T + 1 )
  • 双一次変換:
H(z) = 1 / ( (2/T * (1 - z^-1)/(1 + z^-1)) + 1 )

5. サンプルホールド(ZOH)

サンプルホールドは サンプリング後に次のサンプルまで値を保持する動作。Z 変換では次のように表現されます:

H_ZOH(s) = (1 - e^(-sT)) / (sT)

Z 変換後の効果としては 周波数応答に sinc 特性が乗る。


6. Python 実装イメージ

# Program Name: digital_filter_fd_bd_bilinear.py
# Creation Date: 20250911
# Overview: Compare forward/backward difference and bilinear transform filters with sinusoidal input + ZOH
# Usage: Run and compare time/frequency responses

!pip install numpy matplotlib scipy

import numpy as np
import matplotlib.pyplot as plt
from scipy import signal

# Parameters
T = 0.01          # Sampling period
fs = 1/T
N = 512           # Number of samples
f0 = 5            # Input sine frequency [Hz]

# Input sine
n = np.arange(N)
x = np.sin(2*np.pi*f0*n*T)

# Analog prototype (low-pass: 1/(s+1))
num = [1]
den = [1,1]

# Transformations
# Forward difference
num_fd, den_fd, _ = signal.cont2discrete((num,den), T, method='euler')
# Backward difference
num_bd, den_bd, _ = signal.cont2discrete((num,den), T, method='backward_diff')
# Bilinear
num_bl, den_bl, _ = signal.cont2discrete((num,den), T, method='bilinear')

# Filtering
y_fd = signal.lfilter(num_fd.flatten(), den_fd.flatten(), x)
y_bd = signal.lfilter(num_bd.flatten(), den_bd.flatten(), x)
y_bl = signal.lfilter(num_bl.flatten(), den_bl.flatten(), x)

# Plot
plt.figure(figsize=(10,6))
plt.plot(n*T, x, 'k', label='Input sin')
plt.plot(n*T, y_fd, label='Forward diff')
plt.plot(n*T, y_bd, label='Backward diff')
plt.plot(n*T, y_bl, label='Bilinear')
plt.xlabel("Time [s]")
plt.ylabel("Amplitude")
plt.title("Digital Filters with Different Discretization Methods")
plt.legend()
plt.grid()
plt.show()

まとめ

  • 前進差分:安定性に弱いが簡単
  • 後退差分:安定性に強い
  • 双一次変換:周波数応答の歪みを補正でき、実用的
  • サンプルホールド:ZOH により sinc 特性がかかる → 高周波で信号劣化

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?