Num2str function - string, MATLAB in Engineering

num2str function:

The num2str function, that converts real numbers, can be called in many ways. If only the real number is passed to the num2str function, it will generate a string which has four decimal places, that is the default in MATLAB for showing real numbers. The precision can also be identified (that is the number of digits), and format strings can also be passed, which is as shown below:

>> str2 = num2str(3.456789)

str2 =

3.4568

>> length(str2)

ans =

     6

>> str3 = num2str(3.456789,3)

str3 =

3.46

>> str = num2str(3.456789,'%6.2f')

str =

3.46

Note that in the last illustration, MATLAB eliminate the leading blanks from the string.

 

Posted Date: 10/20/2012 5:42:44 AM | Location : United States







Related Discussions:- Num2str function - string, Assignment Help, Ask Question on Num2str function - string, Get Answer, Expert's Help, Num2str function - string Discussions

Write discussion on Num2str function - string
Your posts are moderated
Related Questions
Function issorted - set operations: The function issorted will return 1 for logical true when the argument is sorted in ascending order (minimum to maximum), or 0 for false wh

Use polyval to evaluate the derivative at xder. This will be the % slope of the tangent line, "a" (general form of a line: y = ax + b). % 4. Calculate the intercept, b, of t

Technique to creating this structure: An alternative technique of creating this structure, that is not as efficient, includes using the dot operator to refer to fields in the

Matrix Multiplication: The Matrix multiplication does not mean multiplying term by term; and it is not an array operation. The Matrix multiplication has a very particular mean

Uses of Function handles: The Function handles can also be generated for functions other than anonymous functions, both built-in & user-defined functions. For illustration, th

Illustration of finding a sting: Let's enlarge this, and write a script which creates a vector of strings which are phrases. The outcome is not suppressed so that the string

printrectarea function: function call: printrectarea(length, width) function header: function printrectarea(len, wid)   In the function call, there are two argume

Illustration of gauss-jordan: Here's an illustration of performing such substitutions by using MATLAB >> a = [1 3 0; 2 1 3; 4 2 3] a = 1 3 0 2 1 3 4 2

Illustration of Matrix solutions: For illustration, consider the three equations below with 3unknowns x 1 ,x 2 , and x 3 : We can write this in the form Ax = b here A

Gauss Elimination: The Gauss elimination technique consists of:    Generating the augmented matrix [A b]    Applying EROs to augmented matrix to obtain an upper trian