function jointStruct = joinStructs(structA, structB) for structCell = {structA, structB} structi = structCell{1} ; for fieldnameCell = fieldnames(structi)' fieldname = fieldnameCell{1} ; jointStruct.(fieldname) = structi.(fieldname) ; end end end