如何创建用于傅里叶变换的符号整数?
我正在 MATLAB 中计算傅里叶变换,当计算系数 C[0]
和 C[n*f0]
时,我得到了非常糟糕的结果,因为 MATLAB 无法识别我的变量“n”为整数。我目前使用“n”作为符号变量(syms n;
)进行计算。如何将符号n
更改为符号整数n
?
I am computing a Fourier transformation in MATLAB, when computing coefficients C[0]
and C[n*f0]
, I got pretty nasty result because MATLAB doesn't recognize my variable "n" as integer. I currently compute with "n" as a symbolic variable (syms n;
). How to change symbolic n
to symbolic integer n
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 MATLAB 文档,要在 R2008b 或更高版本中添加假设“
n
是整数”,您必须编写这回答了您的问题,但是,我不是真的确定它可以解决您的问题。
当您进行傅立叶变换时,您正在对数据执行大量数字运算,因此涉及的所有变量都需要具有具体值。您的 n 可能应该是一个整数,但不仅仅是类型,它应该包含一个实际的数字。如果您使用
syms
声明它,它可能不包含数字,因此您确定您确实需要符号工具箱!如果这样做,并且
n
是产生一个特定整数的计算结果,您可以使用uint32(n)
或类似方法将其转换为正常的数字形式,请参阅转换帮助,例如更新:您在评论中给出的错误消息意味着您的
n
实际上不是整数...我怀疑您是否能够将它与fft一起使用。Looking at the MATLAB documenation, to add the assumption "
n
is integer" in R2008b or later, you have to writeThis answers your question, however, I'm not really sure it solves your problem.
When you do a Fourier transform, you are performing a heavy numeric operation on your data, consequently all variables involved in that need to have concrete values. Your
n
probably should be an integer, but not just by type, it should contain an actual number. If you declare it usingsyms
, it will potentially not contain a number, so you be sure you really need the symbolic toolbox!If you do, and
n
is the result of a calculation that yield one specific integer, you can convert it to normal numerical form usinguint32(n)
or similar, see the help on conversions, e.g.Update: The error message you give in the comment implies that your
n
is in fact not an integer... I doubt you will be able to use it with fft.