Instead of commenting out lines or manually editing expressions, you can filter elements directly in a vector:
x = [1,2,3,4,5]; total = sum(x(~ismember(x, [2 4]))); % Exclude 2 and 4 from the sum