Illustration of a conditional loop, MATLAB Programming

Assignment Help:

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


Related Discussions:- Illustration of a conditional loop

Linspace function, Linspace function: Likewise, the linspace function ...

Linspace function: Likewise, the linspace function generates a linearly spaced vector; linspace(x,y,n) generates a vector with n values in the inclusive range from x to y. For

Off-line signature verification and recognition, Project: "An Efficient Hum...

Project: "An Efficient Human Identification Using Gait Analysis" I want apply/follow the same methodology (Methods/Algorithms) for this paper ("Human Gait Recognition Using Bezi

Function char - characters and encoding, Function char: The function c...

Function char: The function char does the opposite; it converts from any number type to the type char: >> char(numequiv) ans = a As the letters of the alphabet are

Algorithms, Algorithms: Before writing any computer program, it is ver...

Algorithms: Before writing any computer program, it is very useful to first outline the steps which will be essential. An algorithm is the series of steps required to solve a

Singal system , Q.1: Consider the transmission of a sinusoid x(t) = cos(2f...

Q.1: Consider the transmission of a sinusoid x(t) = cos(2f0t) through a channel a ected by multipath and Doppler. Let there be two paths, and assume the sinusoid is being sent fro

Determine the probability - discrete distributions, The occurrence of bushf...

The occurrence of bushfires in the Port Stephens area may be modelled by a Poisson process. The average occurrences of bushfires n is assumed to be either 15 (event A 1 ), 20 (even

Matlab function to find and plot the dft, It is desired to determine the DF...

It is desired to determine the DFT of the analogue signal x (t) = 25 cos(10 Πt)cos(400Πt). (a) Find the Nyquist rate of the signal.   (b) What is the record (signal) length i

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd