A =[ 3.0000 2.2200
5.0000 2.2187
7.0000 2.2171
9.0000 2.2132
11.0000 2.2168
13.0000 2.2277
15.0000 2.2283
19.0000 2.2451];
a=A(1,:);
b=A(2:end,1);
k=1;
jj=1;
idx=[];
while k<=numel(b)
f(jj)=b(k);
if sum(f(1:jj))>=20
idx(end+1)=k;
jj=1;
else
jj=jj+1;
end
k=k+1;
end
out=[a;A(idx+1,:)]
I'am not sure if this is efficient for big matrices
Best Answer