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
Creating Customized strings: There are many built-in functions which create customized strings, including blanks, char, and sprintf. We know that the char function can be u

Built-in functions for Complex numbers:   We know that in MATLAB both i and j are built-in functions which return √-1 (therefore, they can be thought of as built-in constants).

Histogram: The histogram is a particular type of bar chart which shows the frequency of occurrence of the values within a vector. The Histograms use what are known as bins to

Blanks function: The blanks function will generate a string consisting of n blank characters-that are kind of hard to see here! Though, in a MATLAB if the mouse is moved to hi

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

Script a MATLAB program which meets the following speci cations: The program expects an input of a two-variable real-valued continuous function f : R^2--> R The program is to cal

User-defined functions: Therefore, although many functions compute and return values, some do not. A few functions rather merely accomplish a task. Regardless of what type of

Illustration of Advanced file input and output: For illustration, to refer to the third number in the first element of the cell array: >> subjdata{1}(3) ans =

Strcat function - Concatenation : The strcat function, though, will eliminate the trailing blanks from strings before concatenating. Note that in these illustrations, the trail

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