Use of nested if-else statements, MATLAB in Engineering

Assignment Help:

Use of Nested if-else statements:

By using the nested if-else to select from among the three possibilities, not all the conditions should be tested. In this situation, if x is less than -1, the statement is assign 1 to y is then executed, and the if-else statement is done so no other conditions are tested. If, though, x is not less than -1, then the else clause is executed. When the else clause is executed, then we know that x is greater than or equal to -1 so that section does not require to be tested. Rather than that, there are only two remaining possibilities: either x is less than or equal to 2, or it is bigger than 2. An if-else statement is used to select between those two possibilities. Therefore, the action of the else clause was the other if-else statement. Though it is long, this is one if-else statement, and a nested if-else statement. The actions are indented to represent the structure.

Nesting if-else statements in such a way that it can be used to select from among three, four, five, or more options-the possibilities are practically endless!

This is really an illustration of a particular type of nested if-else known as cascading if-else statement. In this category of nested if-else statement, the conditions and actions cascade in the stair-like pattern.

 

 


Related Discussions:- Use of nested if-else statements

Abnormalities on roads, analyzing traffic; determine motion of flow; calcul...

analyzing traffic; determine motion of flow; calculate tracklets; detect abnormalities;

Illustration of initializing the data structure, Illustration of initializi...

Illustration of initializing the data structure: illustration of initializing the data structure by preallocating is here as shown: >> cyls(3) = struct('code', 'c', 'dimen

Solving 2 × 2 systems of equations, Solving 2 × 2 systems of equations: ...

Solving 2 × 2 systems of equations: However this may be easy in a MATLAB, in normal finding solutions to the systems of equations is not. The systems which are 2 × 2 are, thou

Logical scalar values - operators, Logical scalar values: The MATLAB a...

Logical scalar values: The MATLAB also has or and and operators which work element wise for the matrices: These operators will compare any of the two vectors or matric

Algorithm for subfunction, Algorithm for subfunction: The algorithm fo...

Algorithm for subfunction: The algorithm for subfunction askforn is as shown:  Prompt the user for the positive integer n.  Loop to print an error message and reprom

Plotting streamline in matlab, I have a vector of X, one for Y , one for x-...

I have a vector of X, one for Y , one for x-direction velocity U and one for y-direction velocity V. they are at same size. How can I plot streamline of that flow? I follow all exa

Illustration of preallocating a vector, Illustration of Preallocating a Vec...

Illustration of Preallocating a Vector: Illustration of calling the function: >> myveccumsum([5 9 4]) ans =     5  14  18 At the first time in the loop, outvec wil

Use of built-in colormaps - image processing, Use of built-in colormaps: ...

Use of built-in colormaps: MATLAB has built-in colormaps, it is also possible to generate others by using combinations of any colors. For illustration, the following generates

Program to counting in a while loop, Program to Counting in a while loop: ...

Program to Counting in a while loop: The script initializes variable counter to 0. Then, in the while loop action, each and every time the user successfully enter a number, th

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