function [matS]=ECT3D_FEMMatNodes2Simp(vtx,simp,mat)

matS=[];
for i=1:size(simp,1)
    xcent = (vtx(simp(i,1),1)+vtx(simp(i,2),1)+vtx(simp(i,3),1)+vtx(simp(i,4),1))/4;
    ycent = (vtx(simp(i,1),2)+vtx(simp(i,2),2)+vtx(simp(i,3),2)+vtx(simp(i,4),2))/4;
    zcent = (vtx(simp(i,1),3)+vtx(simp(i,2),3)+vtx(simp(i,3),3)+vtx(simp(i,4),3))/4;
    dd = [];
    m = [];
    for j=1:size(simp,2)
        xact = vtx(simp(i,j),1);
        yact = vtx(simp(i,j),2);
        zact = vtx(simp(i,j),3);
        dd = [dd sqrt((xcent - xact)^2 + (ycent - yact)^2 + (zcent - zact)^2)];
        m = [m mat(simp(i,j))];
    end

    matS = [matS; (m(1)*dd(1)+m(2)*dd(2)+m(3)*dd(3)+m(4)*dd(4))./(dd(1)+dd(2)+dd(3)+dd(4))];
end