当前位置:网站首页>MATLAB 学习笔记(6)MATLAB 的 upsample 函数和 downsample 函数
MATLAB 学习笔记(6)MATLAB 的 upsample 函数和 downsample 函数
2022-06-28 23:11:00 【Linest-5】
目录
upsample 和 downsample
upsample 和 downsample 顾名思义就是上采样和下采样,但是在 MATLAB 中代表的含义是什么,用 MATLAB 做个而简单的测验。
以下是 MATLAB 官方对两个函数的解释。


程序验证
上采样 upsample
首先定义一个 1×6 的矩阵 martix_A,并对其 4 倍上采样结果命名为 martix_B。
martix_A = [1 2 3 4 5 6]; martix_B = upsample(martix_A,4);
这是 martix_A 的数据格式

这是 martix_B 的数据格式,这里由于数据太长就没有截全

在工作区可以看出,矩阵 A 为 1×6 的矩阵,而矩阵 B 为 1×24 的矩阵,从上面的表格可以看出,upsample 的功能就是将矩阵中每个数据扩展 4 倍,剩余的 3 个数用 0 填充。

在从具体的图像去分析
下图是原始的 matrix A 的图像,可以看到是一条直线。

下图是由 matrix A 上采样形成的 matrix B 的图像,可以看到现在的图像不再是连续的,而是断断续续的,但是在每个峰的顶点依次对应的值为 1、2、3、4、5、6,而其余的点值均为 0,和之前矩阵的数值就能对应上了。

理解了上采样 upsample 的含义,对于下采样 downsample 就很好理解了,下采样其实就是上采样的逆操作,上采样将一个点扩展到 4 个点,下采样就是将 4 个点缩小至 1 个点,这里依然用实际的程序解释。
下采样 downsample
对 martix_B 进行 4 倍的下采样操作
martix_C = downsample(martix_B,4);
可以看到,此时的 martix_C 和 martix_A 是一致的。

在数据格式上也是一样。

在图像是也是和之前原始的图像一致。

其他参数设定
除此之外,这两个函数还可以添加另一个参数,phase:相位,这个参数可以更改样本数据的相位。
举个栗子
定义一个矩阵 matrix_D,参数 phase 设定为 2
martix_D = upsample(martix_A,4,2);
此时每个数都向右移了 2 位

从图像中也可以看出向右偏移了部分距离

总结
上采样操作将每个输出数据间插入了 3 个 0,这就相当于将采样时间缩短为原来的 1/4,从频率上看,频率变为原来的 1/4。同时数据长度也变为原来的 4 倍。需要注意的是,4 倍升采样后,功率也变为原来的1/4,可以增加增益等方法处理。上采样的意义通俗的讲就在于增加数据与数据直接的间隙,在调制的时候就可以有效的避免产生混叠,下采样的是上采样的逆操作,理解了上采样,下采样自然就懂了。
边栏推荐
- [stm32 HAL库] RTC和BKP驱动
- hiredis的代码示例
- Online linear programming: Dual convergence, new algorithms, and regret bounds
- The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
- 想问问,股票开账户如何优惠开户?网上开户安全么?
- TDD and automated testing
- 网上注册股票开户很困难么?在线开户是安全么?
- leetCode-栈类型详解
- note
- One card can sell tens of millions, and the business expansion is faster than that of players: you don't understand the Jianghu of star cards
猜你喜欢

CIN at QT (the clearest tutorial in the whole network)

一文读懂,WMS仓储管理系统与ERP有什么区别

带链接跳转的微信红包封面制作教程和使用指南

Progress of dbnn experiment
![[word Tutorial Series Part 1] how to remove arrows in word tables](/img/c7/dc57002b0e9d433c4dfac15d53713d.png)
[word Tutorial Series Part 1] how to remove arrows in word tables

This simple little function saves 213 hours for our production research team in half a year
![[stm32 HAL库] RTC和BKP驱动](/img/72/c2c46377d0a2a5a032802640ca0201.png)
[stm32 HAL库] RTC和BKP驱动

Go language - reflect

Counting sorting and stability of sorting

LINQ linked table query
随机推荐
What is the difference between WMS warehouse management system and ERP
Undefined symbol main (referred from entry9a.o).
Is it difficult to register stocks and open accounts online? Is it safe to open an account online?
Leetcode 324 swing sort ii[sort double pointer] the leetcode path of heroding
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
TDD case practice
第五章 虚拟存储器 练习
[deep learning] (3) encoder mechanism in transformer, complete pytoch code attached
Lost in cloud computing
设计电商秒杀系统
2022-06-28: what does the following golang code output? A:true; B:false; C:panic; D: Compilation failed. package main import “fm
一张能卖上千万,商家扩张比玩家还快:球星卡的江湖你不懂
LINQ linked table query
大三,不简单啊!
[matlab] function definition and use
The Best of Many Worlds_ Dual Mirror Descent for Online Allocation Problems
TDD案例实战
想问问,股票开账户如何优惠开户?网上开户安全么?
在长投学堂开通证券账户是安全可靠的吗?
CIN at QT (the clearest tutorial in the whole network)