Illustration of a conditional loop, MATLAB Programming

Illustration of a conditional loop - While loop:

As an illustration of a conditional loop, we will write a function which will find the first factorial which is greater than the input argument high. Formerly, we wrote a function to compute a specific factorial. For illustration, to compute 5! We found the product 1 * 2 * 3 * 4 * 5. In that situation a for loop was used, as it was known that the loop would be repeated 5 times. Now, we do not know how many times the loop will be repeated. The fundamental algorithm is to have two variables, one that iterates throughout the values 1, 2, 3, and so forth, and one which stores the factorial of the iterator at each step. We begin with 1, and 1 factorial, that is 1. Then, we confirm the factorial. If it is not bigger than high, the iterator variable will then increment to 2, and finds its factorial (2). If this is not greater than high, the iterators will then increment to 3, and the function will also find its factorial (6). This continues till we get to the first factorial which is greater than high. Therefore, the process of incrementing a variable and finding its factorial is repeated till we get to the first value greater than high. This is implemented by using a while loop:

1371_Illustration of a conditional loop.png

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







Related Discussions:- Illustration of a conditional loop, Assignment Help, Ask Question on Illustration of a conditional loop, Get Answer, Expert's Help, Illustration of a conditional loop Discussions

Write discussion on Illustration of a conditional loop
Your posts are moderated
Related Questions
Hello my name is lalitkumar and I am a student.I needed help in MATLAB for recognition of colour randomly using webcam realtime for RGB without external trigger.please mail the co

The following four 4 equations are needed to be plotted as CONTOUR lines on the axes space (C, T) where C is the horizontal axis, and T is the vertical axis. Contour lines for

Illustration to logical function: In addition to such logical operators, the MATLAB also has a function xor, that is the exclusive or function. It returns the logical true if

Random numbers: Whenever a program is being written to work with a data, and the data is not yet available, it is frequently useful to test the program first by initializing t

i need help with a monte carlo simulation. I have most of the code, but I can''t get it to plot correctly

Need help programming in Matlab for airy equations

Compare results/performance with tridiagonal Gaussian elimination solver for the problem arising from -y''=f   on (0,1) with y(0)=0=y(1). You may also need to use sparse storage an

A file houseafford.dat stores on its three lines years, median incomes and median home prices for a city. The dollar amounts are in thousands. For example, it might look like this:

Looping Statements: Consider the problem of computing the area of a circle with radius of 0.3 centimeters-a MATLAB program certainly is not required to do that; you would use

User-Defined Functions which return a Single Value: We have seen the use of many functions in the MATLAB. We have used many built-in functions like fix, sin, abs, double, and