Illustrations of if statement, MATLAB Programming

Illustrations of if statement:

illustrations of running this script:

>> sqrtifexamp

Please enter a number: -4.2

The sqrt of 4.2 is 2.0

>> sqrtifexamp

Please enter a number: 1.44

The sqrt of 1.4 is 1.2

In this situation, the action of the if statement was a single assignment statement.

The action can be several numbers of valid statements. For illustration, we might wish to print a note to the user to state that the number entered was being changed.

959_Illustrations of if statement.png

>> sqrtifexampii

Please enter a number: -25

OK, we will use the absolute value

The sqrt of 25.0 is 5.0

Note that the use of two single quotes in the disp statement in order to print the one single quote.

Posted Date: 10/19/2012 3:16:18 AM | Location : United States







Related Discussions:- Illustrations of if statement, Assignment Help, Ask Question on Illustrations of if statement, Get Answer, Expert's Help, Illustrations of if statement Discussions

Write discussion on Illustrations of if statement
Your posts are moderated
Related Questions
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

how to obtain matlab coding for the market clearing price

what are data collect this topic,how i can create algorithm in mat lab what language support easy to this topic

Appending data to a data File: A text file once exists; the data can be appended to it. The format is similar as formerly, with the addition of the qualifier -append. For illu

Call to length function: The call to length function consists of the name of the function, followed by an argument in the parentheses. This function takes the argument, and re

Calling a Function: Here is an illustration of the call to this function in which value returned is stored in the default variable ans: >> calcarea(4) ans = 50.2655

Type logical: The type logical is used to store the true/false values. If any variables have been formed in the Command Window, they can be seen at the Workspace Window. In

Format command: The format command can be used to control the spacing between the MATLAB command or expression and the outcome; it can be either compact or loose. >> format

Show the output - algorithms: Where does the output go? The two possibilities are (i) to an external file, or (ii) to a window on the screen. Based on system, one of these wil

Illustration of Output statements: For illustration, >> disp('Hello') Hello >> disp(4^3)   64 The formatted output can be printed to the screen by using the fpr