Counting in a while loop, MATLAB in Mathematics

Counting in a While Loop:

Whenever it is not known ahead of the time how many values will be entered into the script, it is often essential to count the number of values which are entered. For illustration, if numbers are read into the script, and then the average of the numbers is preferred, the script should add them together, and keep the track of how many there are, in order to compute the average. The variation below on the script counts the number of numbers which the user successfully enters:

1537_Counting in a While Loop.png

Posted Date: 10/19/2012 6:10:20 AM | Location : United States







Related Discussions:- Counting in a while loop, Assignment Help, Ask Question on Counting in a while loop, Get Answer, Expert's Help, Counting in a while loop Discussions

Write discussion on Counting in a while loop
Your posts are moderated
Related Questions
Sorting The Sorting is a process of putting a list in order; either in descending (maximum to minimum), or ascending (minimum to maximum) order. For illustration, here is a li

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Function isreal - complex numbers: The function isreal returns 1 for logical true when there is no imaginary part of the argument, or 0 for false when the argument does have a

Illustration of logical built-in functions: The function find returns the indices of a vector which meet certain criteria. For illustration, to find all the elements in a vect

User input in the while loop: Here is an illustration of running this script: >> readonenum Enter a positive number: -5 Invalid! Enter a positive number: -2.2

Three-dimensional pie and bar: For the bar3 function, x & y vectors are passed and the function displays three-dimensional bars as shown in figure: Figure: Three-dimen

Error-Checking for Integers: As MATLAB uses the type double by default for all the values, to check to make confirm that the user has entered an integer, the program have to c

Refer the subset of a matrix: It is also possible to refer to the subset of a matrix. For illustration, this refers to the first & second rows, second & third columns: >> m

Types of User-defined Functions: We know how to write a user-defined function, stored in an M-file, which computes and returns one value. This is merely one type of the functi

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer