clear all;
clc;
rand('seed',0);
a=rand(1,24);
a=sort(a);
for j=1:1:24-7
b=[];
for i=1:24-j
b(i)=a(i+1)-a(i);
end
c=find(b==min(b));
a=[a(1:c-1) (a(c)+a(c+1))/2 a(c+2:end)];
-----------運行結果
a = 0.0405 0.2190 0.4001 0.5564 0.6655 0.8386 0.9326