function [nstruct] = struct_add(ostruct, addstruct);
% concatenate two structs. Fields in both structs are concatenated
% any field in one  struct, not in the other, is added 
% 2011/02/11  note: 
% fields must be shaped like 1,Npts, not Npts,1 !!!
% 
dbug=0;
fno=fieldnames(ostruct);
for i=1:size(fno,1)
    field_name=fno{i};
    if dbug == 1, fprintf('%s\n', field_name); end;

    if isfield(addstruct, field_name)
       cmd=['nstruct.' field_name ' =  [ ostruct.' field_name ' addstruct.' field_name '];'];
    else
       cmd=['nstruct.' field_name ' =  ostruct.' field_name ';'];
    end
    eval(cmd);
end

% in this version, a
fno=fieldnames(addstruct);
for i=1:size(fno,1)
    field_name=fno{i};
    if ~isfield(ostruct, field_name)
        cmd=['nstruct.' field_name ' =  addstruct.' field_name ';'];
        eval(cmd);
    end
end
