Octave/MATLAB: How to compare structs for equality?

前端 未结 2 1366
猫巷女王i
猫巷女王i 2020-12-10 11:22

How do I compare two structs for equality in octave (or matlab)?

Attempting to use the == operator yields:

binary operator `==\' not implemented for          


        
2条回答
  •  伪装坚强ぢ
    2020-12-10 11:37

    I would just write a function isStructEqual(struct1,struct2) that performs regular comparisons on all of the member attributes. If any such comparison returns 'false' or '0', then immediately exit and return 'false', otherwise if it makes it all the way through the list of member attributes without that happening, return true. If the struct is extremely large, there are ways to automate the process of iterating over the member fields.

    Looking on the central file exchange, you might try this file.

提交回复
热议问题