Labels and prompts, MATLAB in Mathematics

Labels and Prompts:

The script loads all the numbers from file into a row vector. It then splits the vector; it stores the initial element that is the experiment number in a variable exper_no, rest of the vector in a variable data (the rest being from the next element to the end). It then plots the data, by using sprintf to generate the title which includes the experiment number as shown in the figure.

438_Labels and Prompts1.png

 

The other way of completing this (in script or function) would be as shown:

fprintf('%s, Enter your id #: ',username);

id_no = input('');

 

Note that the calls to the sprintf and fprintf functions are similar except that the fprintf prints (therefore there is no requirement for a prompt in the input function) while the sprintf generates a string which can then be exhibited by the input function. In this situation by using sprintf it seems clearer than using the fprintf and then having an empty string for the prompt in input.

 

Posted Date: 10/20/2012 5:19:48 AM | Location : United States







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

Write discussion on Labels and prompts
Your posts are moderated
Related Questions
Writing variables to a File: The save command is used to write variables to a file, or to append the variables to a MAT-file. By the default, save function writes to a MAT-fil

Differentiation: The derivative of a function y = f(x) can be written as follows or f  '(x) and is defined as the rate of change of the dependent variable y with respe

Example of Symbolic Expression When there is more than one variable, the MATLAB selects which to solve for. In the illustration below, the equation ax 2 + bx = 0 is solved. Th

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).

Illustration of logical built-in functions: The function find returns the indices of a vector which meet certain criteria. For illustration, to find all the elements in a vect

Illustration of a recursive function: illustration is of a recursive function which does not return anything, but simply prints. The below function prtwords receives a sentenc

Logical Vectors: The relational operators can also be used with the vectors and matrices. For illustration, let's say that there is a vector, and we want to compare each eleme

Illustration of Writing to files: Here is the other illustration in which a matrix is written to a file. At First, an arbitrary 2 × 4 matrix is generated, and then it is writt

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, th

Creating string Variables: The string consists of a few numbers of characters (including, possibly, none). These are the illustrations of the strings: '' 'x' 'ca