Matlab 中的离散化函数
我有以下函数和一组值:
z(t): {R → [-2,3] | z(t) = sin(0.5×π×t) + cos(2×π×t) + 1
t = [-1 : 0.001 : 1]
我需要使用采样周期 Ts=0.01
确定 z(n×Ts) = z(n)
,因此离散化的功能。
我尝试使用 d2d,但据我所知只能应用于 zpk 函数。
还有其他方法吗?
I have the following function and set of values:
z(t): {R → [-2,3] | z(t) = sin(0.5×π×t) + cos(2×π×t) + 1
t = [-1 : 0.001 : 1]
I need to determine z(n×Ts) = z(n)
, using the sample period Ts=0.01
, therefore discretizing the fucnction.
I tried using d2d, but for what I've understood can only be applied to zpk functions.
Is there any other way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要信号的零阶保持近似,可以通过以下代码来完成:
这将为您提供如附图所示的输出。
您可以尝试使用 ceil() 或 round() 而不是 Floor() 来获得略有不同的行为。如果您只需要 n 整数值的样本,那就完全不同了,并且对于一般情况来说实现起来也有很大不同(由于浮点数的舍入误差)。但是:对于您的情况,只需像 nSampled 中那样对索引进行二次采样即可工作,因为二次采样因子为 10。对于非整数二次采样因子,这将无法正常工作。
If you want a zero order hold approximation of your signal, this can be done by following code:
This will give you the output as in the attached figure.
You can try to play with ceil() or round() instead of floor() to get slightly different behavior. If you only need samples at integer values of n, that is something different altogether and is quite different to achieve for the general case (due to roundoff error in floats). However: for your case it will work by simply subsampling the index as is done in nSampled as the subsampling factor is 10. For a non-integer subsampling factor, this will not work properly.