compareStruct compares Structs fields and returns logical 1 (true) if the input structs have the same fields, and logical 0 (false) otherwise, no matter their content.
Marco Borges (2021). compareStruct (https://www.mathworks.com/matlabcentral/fileexchange/40124-comparestruct), MATLAB Central File Exchange. Retrieved .
Hey Jos(10584), sorry for the delay in notice that the code had not been updated!
Just send version 2 reviewed in February!
Something seems amiss. I do not see any code changes, Marco.
Thanks for the suggestions. Were accepted and the code remade.
The code can be replaced by a one-liner:
B = isequal(sort(fieldnames(a)), sort(fieldnames(b)))
I do like the fact that you have written a clear help section, including a H1 line. As for your code, as soon as B becomes false in the for-loop you can issue a return command (no need to check the remaining field names).
You also might want to check if the input are indeed structures.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!