From: us on 5 Aug 2010 15:13 "DLH " <nospam(a)nospam.com> wrote in message <i3eg55$6bs$1(a)fred.mathworks.com>... > Is there a way (command/s) to diff a structure similar to diff'ing files on a unix/linux system? I have a several structures with dozens of fields, both strings & numbers, and I'd like a quick and simple way of findings which fields are different and what those differences are. Any suggestions? > > Thanks, > dlh a hint: - this FEX submission will completely dissect a STRUCT - the output struct contains information re the anatomy the content - this makes it very easy to comapere STRUCTs - see example below http://www.mathworks.com/matlabcentral/fileexchange/1348 clear s; % <- save old stuff! s.a=pi; s.b.c=magic(3); s.d.e.f={struct('a','foo'),'goo',{magic(3)}}; s.g(2,2)=s; [fa,fc,fs]=gettok(s,'-f',-3,'-Q'); % <- the call... disp(fs.field); % <- == fa %{ % note: see original version for correct formatting... % col 1: field syntax (EVALuable) % col 2: field content 's.a' [ 3.1416] 's.b.c' [3x3 double] 's.d.e.f{1,1}.a' 'foo' 's.d.e.f{1,2}' 'goo' 's.d.e.f{1,3}{1,1}' [3x3 double] 's.g(1,1).a' [] 's.g(1,1).b' [] 's.g(1,1).d' [] 's.g(2,1).a' [] 's.g(2,1).b' [] 's.g(2,1).d' [] 's.g(1,2).a' [] 's.g(1,2).b' [] 's.g(1,2).d' [] 's.g(2,2).a' [ 3.1416] 's.g(2,2).b.c' [3x3 double] 's.g(2,2).d.e.f{1,1}.a' 'foo' 's.g(2,2).d.e.f{1,2}' 'goo' 's.g(2,2).d.e.f{1,3}{1,1}' [3x3 double] %} us |