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
I have a frequency response data. How do I convert that to state space? I am given a 6 row and 3 column data (steady state). How do i convert that to state space model?

Dot Product: The dot or inner product of two vectors a and b is written as a • b and is defined as  In another words, this is like matrix multiplication when multiplyi

Function cellplot - Cell array: The function cellplot place a graphical display of the cell array in a figure Window; though, it is a high-level view and fundamentally just di

Evaluating a string: The function eval is used to compute a string as a function. For illustration, below is the string 'plot(x)'is interpreted to be a call to plot the functi

Function rmfield - structure: The function rmfield eliminates a field from the structure. It returns a new structure with field eliminated, but does not modify the original st


analyzing traffic; determine motion of flow; calculate tracklets; detect abnormalities;

Expanding a function: The expand function will multiply out terms, and factor will do the opposite: >> expand((x+2)*(x-1)) ans = x^2 x-2 >> factor(ans)

Logical scalar values: The MATLAB also has or and and operators which work element wise for the matrices: These operators will compare any of the two vectors or matric

Set Operations: The MATLAB has numerous built-in functions which perform set operations on vectors. These involve intersect, union, setdiff, unique, and setxor. All these func