如何比较 matlab 单元格或结构体
可能的重复:
Octave/MATLAB:如何比较结构是否相等? < /p>
是matlab 单元或结构对象有一个简单的比较函数吗? 使用 '==' 似乎不起作用:(
Possible Duplicate:
Octave/MATLAB: How to compare structs for equality?
is there a simple comparison function for matlab cell or struct objects?
using '==' doesn't seem to work :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想知道两个元胞数组或结构对象是否完全相同,您可以随时使用 等号。
If you want to know if two cell arrays or struct objects are exactly equal you could always use isequaln.
使用
isequal
比较两个单元格。但请注意,即使对于数组,也不建议使用==
:例如,您需要使用进一步的技巧在 if 语句中使用该表达式。
不建议将
==
用于double
类型的变量,原因是 MATLAB 使用 IEEE 754 表示形式。例如:要更稳健地比较双精度值,您可以使用 MATLAB 中的
abs
函数:Use
isequal
to compare two cells. Note however that==
is not advised even for arrays:You would need to use a further trick to use that expression in a if statement for instance.
The reason
==
is not recommended for variables of typedouble
is because of the IEEE 754 representation use by MATLAB. For instance:To compare double values more robustly, you can use the
abs
function in MATLAB: