MATLAB: Sum, vector elements, except i-th

elementssumvector

hi,
how can I sum vector elements, say v = rand(1,30), except 12th one?
thanks,

Best Answer

You can always do the sum, then subtract that single element, 12th, from the sum.
v = rand(1,30);
sum_except12=sum(v)-v(12)