Code covered by the BSD License  

Highlights from

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.6 KB File ID: #40124 Version: 1.3




01 Feb 2013 (Updated )

Compare Structs fields

| Watch this File

File Information

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.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
30 Apr 2013 Marco Borges

Hey Jos(10584), sorry for the delay in notice that the code had not been updated!
Just send version 2 reviewed in February!

Comment only
13 Feb 2013 Jos (10584)

Jos (10584) (view profile)

Something seems amiss. I do not see any code changes, Marco.

Comment only
07 Feb 2013 Marco Borges

Thanks for the suggestions. Were accepted and the code remade.

Comment only
04 Feb 2013 Jos (10584)

Jos (10584) (view profile)

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.

Comment only
07 Feb 2013 1.2

Changes suggested by the user Jos (10584) accepted!

01 May 2013 1.3

v2 : Changes compare struct like Jos (10584) mention

Contact us