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

Standard Deviation The standard deviation is the square root of variance: The built-in function in a MATLAB for the standard deviation is known as std; the standard dev

Strings as matrix: The matrix can be generated, that consists of strings in each row. Therefore, essentially it is created as a column vector of strings, but the final result

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Common form of the switch statement: The common form of the switch statement is as shown below:   switch switch_expression   case caseexp1    action1   case cas

Polar Form: Any complex number z = a + bi can be thought of as a point (a,b) or vector in the complex plane in which the horizontal axis is the real part of z, and the vertica

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

Writing to Files: There are many lower level functions which can write to files. We will focus on the fprintf function that can be used to write a file and also to append to a

Illustration of Logical vectors: Calling the function appears to return similar vector as simply vec > 5, and summing the result still works to determine how many elements wer

bar and barh functions: For a matrix, the bar and barh functions will group altogether the values in each and every row. The illustration is as shown: rm = randint(2,4,[1