Structured variables are good for organizing data and manipulating data. However, they can be difficult to check for errors or differences. Function allows each field of a structure to be checked against a corresponding field in a separate structure. Possible outcomes are:
1. Fields agree (both exist and have the same content)
2. Fields do not agree (both exist but contents / values are different)
3. Field exists in only one structure
4. Field type differs (variable class disagreement)
______________________________________
This is a scratch re-write of the code taking advantage of new abilities in MATLAB since I wrote the first version 10 years ago. Original version was just something I wrote in desperation and was not very elegant. This version should be more usable. Original version is included for posterity.
Calling syntax is similar to the original but now you can:
1. Disable all printouts to screen, print out only missing fields, print out all errors, or print out all errors and matches.
2. Activate a waitbar for progress (use if you are not printing out errors and your structures are large)
3. Collect all errors into a single cell (rather than two cells for each structure)
4. Structure order does not matter. Tool looks for matching fields.
Thanks to Brian for suggestions and a validation test. Thanks to David Groppe for the error only output suggestion. Thanks to David Provencher for the output only suggestion. Thanks to Keith Beardmore for pointing out the sort order issue.
|