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
An environmental consulting firm is conducting a site investigation on an abandoned industrial site that is 200 m by 150 m in size (Fig. 1). A number of piezometers were installed

ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7-6 6-8 7-8 THE COMMPANY LOSES 2,000 FOR EVERY WEEK THE PROJECT LASTS BEYOND 30 WEEKS. fOR EACH OF THE PROPOSALS; ACTIVI

Scripts to Produce and Customize the Simple Plots: The MATLAB has many graphing capabilities. In most cases, customizing plots are desired and this is the simplest to accompli

please send the matlab program to find mean,variance,standard deviation and kurtosis for a set of values?

Creating row Vectors: There are many ways to generate row vector variables. The most important way is to put the values which you want in the vector in square brackets, separa

Strings: The MATLAB also handles strings that are a sequence of characters in single quotes. For illustration, using the double function on a string will represent the equival

whats thye procedure for entering say an LP model, maximisation an objective funtion ''10x+3y'' subject to: 40 300x +298y>=299 x+y=1

Problem: A function is given by Y= 2x3 + 3 x2 -12x + 5 a determine the finite values of x at which any local maximum of minimum occur and determine the corresponding val

Write a function called threshold2 (in a file called 'threshold2.m'). The function takes an arbitrary number of input variables. The first input variable, t, is required and is the

Create a text file with simulated data. Calculate an experimental y using the first function and some reasonable values for the parameters Add noise Save the x values and ca