function Jstruct=MisfitDeinterlace(misfit,type) %MISFITDEINTERLACE - deinterlace misfits that are mixed together, using type. % % Usage: % Jstruct=MisfitDeinterlace(misfit,type) % % Example: % Jstruct=MisfitDeinterlace(md.results.stressbalance.J,md.fit) % % Jstruct=struct(); count=1; for i=0:max(type), pos=find(type==i); if length(pos), Jstruct(count).type=i; Jstruct(count).J=misfit(pos); count=count+1; end end