If-else statement, MATLAB Programming

Assignment Help:

The IF-ELSE Statement:

The if statement selects whether an action is executed or not. Selecting between the two actions, or selecting from numerous actions, is accomplished by using if-else, nested if, and switch statements.

The if-else statement is used to select between the two statements, or sets of statements. The common form is as shown below:

if condition

action1

else

action2

end

 

At First, the condition is computed. If it is theoretically true, then the set of statements elected as action1 is executed, and that is it for the if-else statement. If rather the condition is theoretically false, the second set of statements elected as action2 is executed, and that is it. The first set of statements is known as the action of the if clause; it is what will be executed if the expression are true. The second set of statements is known as the action of the else clause; it is what will be executed if the expression is false. One of these actions, and only one, will be executed-that one depends on the value of the condition.

For illustration, to establish and print whether or not a random number in the range from 0 to 1 is less than 0.5, an if-else statement can be used:

if rand < 0.5

disp('It was less than .5!')

else

disp('It was not less than .5!')

end


Related Discussions:- If-else statement

Visual cryptography, how to implement 3 out of 4 visual cryptography in MAT...

how to implement 3 out of 4 visual cryptography in MATLAB?

Algebra, the cost t in hundreds of dollars of tuition and fees at many comm...

the cost t in hundreds of dollars of tuition and fees at many community college can be approximated by t=1/2c+5 where c is the number of credits for which a student registers. ( 2

Create a vector representing x coordinates of a measurement, Problem 1. Cr...

Problem 1. Create a vector representing x coordinates of a measurement with 20 points between 0 and 10. Create another vector y representing fake measurements which are related to

#numerical Analysis, using newton divided diference formula find f(15) and ...

using newton divided diference formula find f(15) and f (8)

#title.s.tudent, AApproximate the number to the hundredth, ten-thousandths,...

AApproximate the number to the hundredth, ten-thousandths, and one-hundredmillionth.sk question #Minimum 100 words accepted#

Functions, Need help with creating functions in matlab.

Need help with creating functions in matlab.

Compute the sum of all the columns of a matrix, 1. Enter the 3×4 matrix ...

1. Enter the 3×4 matrix Let a ij denote the entry of A in the ith row and jth column. Use Matlab to compute the following : (a) a 13 + a 32 (b) Three times the

Estimate the sample mean and sample standard deviation, The fuel consumptio...

The fuel consumption of a certain make of car may not be exactly that rated by the manufacturer. Suppose ten cars of the same model were tested for combined city and highway fuel c

Write a matlab script to calculate the frequency response, A band pass FIR ...

A band pass FIR filter is required to pass frequencies from 5KHz to 8KHz, using a sample rate of 40K i) Explain how this would map to normalization sampling frequencies in radia

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