Main Difference – Amplitude vs. Magnitude

本文转自https://pediaa.com/difference-between-amplitude-and-magnitude/

Amplitude and magnitude are both terms used to describe properties of quantities. The main difference between amplitude and magnitude is that amplitude refers to the furthest values that a quantity can take from 0 whereas magnitude refers to the size of a quantity regardless of direction.

What is Amplitude

The term amplitude describes the maximum and minimum values reached by a periodically changing quantity. Typically, the term is used with quantities that vary sinusoidally. In this context, amplitude refers to the maximum deviation from the equilibrium. i.e. if the quantity x can be described with an equation in the form of x(t)=A\mathrm{sin\:}2\pi ft, then A is the amplitude.

When the amplitude A of a wave is proportional to the wave’s energy, the intensity of the wave (that is, the power transmitted by the wave per unit area) is proportional to the square of its amplitude. When we describe simple harmonic motion, amplitude refers to the maximum displacement of the oscillating object from the equilibrium position.

 

What is Magnitude

Magnitude refers to the size of a quantity, regardless of the quantity’s direction (if the quantity has one). For a vector \vec{a} of n dimensions \vec{a}=\left( a_1,a_2,a_3,\cdots a_n \right), the magnitude \left| \vec{a}\right| is given by:

\sqrt{​{a_1}^2+{a_2}^2+\cdots +{a_3}^2}

Since no direction is associated with a magnitude, the magnitudes of vector quantities are scalar quantities. For instance, the magnitude of displacement is the distance, and the magnitude of velocity is speed, both of which are scalars.

Magnitude is also the of a unit in astronomy that measures the brightness of astronomical objects. Earthquakes are described using “magnitudes” along the Ritcher scale.

Difference Between Amplitude and Magnitude

Amplitude refers to the maximum deviation from zero that can be taken by a periodically varying quantity.

Magnitude refers to the size of a quantity regardless of the direction.

### 如何使用 `matplotlib.pyplot.magnitude_spectrum` 去除直流分量 在信号处理中,直流分量通常是指频率为零的成分。为了去除信号频谱中的直流分量,可以通过以下方法实现: 1. **计算信号的均值并将其从原始信号中减去**:这一步会有效地消除直流偏移[^1]。 2. **利用 `magnitude_spectrum` 函数绘制修改后的信号频谱**:该函数能够显示信号幅值随频率的变化情况。 以下是具体的操作代码示例: ```python import numpy as np import matplotlib.pyplot as plt # 定义信号参数 A = 1.0 # 幅度 f = 5.0 # 频率 (Hz) phi = 0 # 相位 (弧度) T_s = 0.01 # 采样周期 (s) N = 200 # 采样点数 # 生成时间轴 n = np.arange(N) t = n * T_s # 生成带有直流分量的周期信号 dc_offset = 0.5 # 添加一个直流分量 x_n_with_dc = A * np.sin(2 * np.pi * f * t + phi) + dc_offset # 移除直流分量 mean_value = np.mean(x_n_with_dc) x_n_without_dc = x_n_with_dc - mean_value # 绘制原信号与时域波形图 plt.figure(figsize=(10, 4)) plt.subplot(2, 1, 1) plt.plot(t, x_n_with_dc, label='Original Signal with DC Offset') plt.title('Original Signal with DC Component') plt.xlabel('Time (s)') plt.ylabel('Amplitude') # 使用 magnitude_spectrum 显示频谱对比 plt.subplot(2, 2, 3) plt.magnitude_spectrum(x_n_with_dc, Fs=1/T_s, color='b', scale='dB') plt.title('Magnitude Spectrum with DC Component') plt.subplot(2, 2, 4) plt.magnitude_spectrum(x_n_without_dc, Fs=1/T_s, color='r', scale='dB') plt.title('Magnitude Spectrum without DC Component') plt.tight_layout() plt.show() ``` 上述代码展示了如何通过减去信号的平均值来有效去除直流分量,并使用 `magnitude_spectrum` 对比有无直流分量时的频谱差异。 #### 结果分析 - 在未去除直流分量的情况下,频谱会在零频率处显示出显著的能量峰值。 - 当成功去除直流分量后,零频率处的能量峰值消失,仅保留其他频率成分的信息。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值