专栏
标签
Syslab在M兼容下使用resample函数报错:resample(x,p,q),6个参数不足
技术分享
发布于 2024-09-11 20:37:28
查看 4过去629天

一、问题现象

Syslab在M兼容下使用resample函数报错:resample(x,p,q),6个参数不足。

代码:

fs = 10

t1 = 0:(1 / fs):1

x = t1

y = resample(x,x,50,1,1,'pchip')

image.png

二、解决方法 / 步骤

针对上述问题,M兼容的函数写法参考Matlab,但函数用法是基于Julia的,上述resample函敖的用法在Julia中并不支持,因此在M兼容中会出现报错。

1.将上述代码修改为以下:

fs = 10

t1 = 0:(1 / fs):1

x = t1

%y = resample(x,x,50,1,1,'pchip')

y = resample(x,50,1,1) %参考Julia用法,删除多余的输入项

2.启动M命令行:
image.png
3.在M命令行下运行上述代码,得到正确结果:
image.png
4. resample函数的用法:

函数库:TySignalProcessing

语法:

y, = resample(x, p, q)

y, = resample(x, p, q, n)

y, = resample(x, p, q, n, beta)

y, = resample(x, p, q, b)

y, b = resample(x, p, q, ___)

___ = resample(___; dims = dims)

说明:

y, = resample(x, p, q) resample对输入序列x以原始采样率的p/q倍进行重采样,对x应用FIR反锯齿低通滤波器,并对滤波器引入的延迟进行补偿。该函数沿着第一个长度大于1的数组维度操作。

示例:

using TyPlot

using TySignalProcessing

fs = 10

t1 = 0:(1 / fs):1

x = t1

y, = resample(x, 3, 2)

t2 = [0:(length(y) -1);] * 2 / (3 * fs)

figure(1)

plot(t1, x, "*", t2, y, "o")

xlabel("Time (s)")

ylabel("Signal")

legend(["Original", "Resampled"])

image.png

所属专栏:Syslab基础平台
产品信息:Syslab科学计算环境
科学计算

全部回答

暂无数据
暂无数据
用户
和原帖交流更多问题细节吧,去
我要发帖 我要发帖
资料中心 资料中心
查看更多>
热门帖子 热门帖子
主要贡献者 主要贡献者
过去7天