%% Code segment to sum the elements of a vector total = 0; for i = 1:length(x) total = total + x(i); end ts = ['Total of vector x = ' num2str(total)]; disp(ts)