function s = mysum(x); % compute the sum of the components of vector x s = 0; % variable to hold partial sum n = length(x); % get length of vector x fprintf('Will need to do %d additions.\n\n', n); for i=1:n fprintf('The current partial sum is s = %f.\n\n', s); pause fprintf('Add %f.\n', x(i)); s = s + x(i); end fprintf('The total sum is s = %f.\n', s); pause end