function V=Get_V_Mat(Bdofs,Ndofs) V0=eye(Ndofs,Ndofs); %Prepare permuation vector IndexAll=[1:1:Ndofs]'; IndexFree=setdiff(IndexAll,Bdofs); PermutationV=[IndexFree;Bdofs]; %Now permute the rows of the identity matrix V=V0(PermutationV,:); end