I think I found the answer.
i=1; n=1; while n >= 0 ix = input('Enter your numbers: '); if ix < 0 % break else x(i)= ix; end i=i+1; end %gm is geometric mean. avg is the average n = length(x); gm = 1; % Initialize variable for i = 1 : n % Iterate through all of the elements y = x(i); gm = gm * y^(1/n); % Compute mean end avg = sum(x)/n; % Compute average fprintf('The Geometric mean is %.3f \n',gm) fprintf('The average is %.3f \n',avg)