clc;clearA=[1 1 2 2 2 3 4 4 5 5]B=[1,3,5]for m=1:length(B)C(m,:)=A-B(m) %A的每个元素减去B的每个元素endD=1./C%倒数,下面要用到E=isinf(D)%没有iszero函数,只好这样啦F=B*EG=F(find(F~=0))