I want create a program that continuously asks the user to enter numbers until the user enters a negative number. The numbers before the last one (non-negative numbers) are saved in a vector B. Then I want to display B and the average value in B. For instance, if the user enters 3, 5, 0, 7, 11, -3, the input stops and B is [3, 5, 0, 7, 11]. The average value of B is 5.2.
I know how to do it with the built-in functions of Matlab, but can not figure out how to do it with the loop method. Help !
Thanks,
Best Answer