function diffstructs(S1,S2)


if nargin==0
    
    S1.a = 1;
    S1.b = 'hello world';
    S1.c = pi;

    S2.a = 1;
    S2.b = 'hello word';
    
end
    
    
F1 = fieldnames(S1);
F2 = fieldnames(S2);
FBoth = unique(vertcat(F1,F2));

if isequal(S1,S2)
    disp('Structure arrays are equal.')
else
    disp(' ')
    for k=1:numel(FBoth)
        if ~isfield(S1,FBoth{k})
            disp(['Field ',char(39),FBoth{k},char(39),' not present in first structure array.'])
        end
        if ~isfield(S2,FBoth{k})
            disp(['Field ',char(39),FBoth{k},char(39),' not present in second structure array.'])        
        end
        if isfield(S1,FBoth{k}) & isfield(S2,FBoth{k})
            eval(['IO = isequal(S1.',FBoth{k},',S2.',FBoth{k},');']);
            if ~IO
                disp(['Value of field ',char(39),FBoth{k},char(39),' differs.'])
            end
        end    
    end
    disp(' ')
end
