Illustration of labels and prompts, MATLAB in Mathematics

Illustration of Labels and prompts:

The program below prompts the user for endpoints (x1, y1) and (x2, y2) of a line segment, and computes the midpoint of the line segment, that is the point (xm, ym). The coordinates of the midpoint are found by:

776_Illustration of Labels and prompts.png

The script midpoint.m calls a function entercoords to individually prompt the user for the x- and y-coordinates of the two endpoints, calls the function findmid which computes individually the x- and y-coordinates of the midpoint, and then prints this midpoint. Whenever the program is executed, the output appears like this:

>> midpoint

Put the x coord of the first endpoint: 2

Set the y coord of the first endpoint: 4

Put the x coord of the second endpoint: 3

Set the y coord of the second endpoint: 8

The midpoint is (2.5, 6.0)

 

In this illustration, the word 'first' or 'second' is passed to the entercoords function so that it can use wherever the word is passed in prompt. The sprintf function creates this customized prompt.

779_Illustration of Labels and prompts1.png

2112_Illustration of Labels and prompts2.png

1264_Illustration of Labels and prompts3.png

 

Posted Date: 10/20/2012 5:23:26 AM | Location : United States







Related Discussions:- Illustration of labels and prompts, Assignment Help, Ask Question on Illustration of labels and prompts, Get Answer, Expert's Help, Illustration of labels and prompts Discussions

Write discussion on Illustration of labels and prompts
Your posts are moderated
Related Questions
Symbolic Expression The solve function solves an equation and returns the solution(s) as symbolic expressions. The answer can be converted to numbers by using any numeric funct

Three-Dimensional Plots: The MATLAB has many functions which will display three-dimensional plots. Most of these functions have similar name as corresponding two-dimensional p

Referring to and Modifying the Matrix Elements: To refer to matrix elements, the row and then the column indices are given in parentheses (always the row index initially and t

Illustration of Variance For illustration, for the vector [4, 6, 1, 5], there are n = 4 values therefore n - 1 is 3. The mean of this data set is also 4. The variance will be

Fliplr function: The fliplr function "flips" the matrix from left to right (in another words the left-most column, the first column, become the last column and so on), and the

Program of built-in factorial function: Calling this function yields similar result as the built-in factorial function: >> fact(5) ans =   120 >> factorial(

Empty Vectors: An empty vector or in another words, a vector which stores no values, can be generated using the empty square brackets: >> evec = [] evec = [] >> lengt

fprintf function - File function: The fprintf function really returns the number of bytes which was written to the file, therefore if you do not want to see that number, suppr

Function xlsread - file function: The function xlsread will read from the spreadsheet file. For illustration, to read from file just generated: >> ssnums = xlsread('ranexc

Error-checking for integers: illustrations of running this script as shown below: >> readoneint Enter an integer: 9.5 Invalid! Enter an integer: 3.6 Invalid