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
Creating a cell array: The other method of creating a cell array is easy to assign values to particular array elements and build it up element by element. Though, as explained

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

ischar function: The ischar function return the logical true if an array is a character array, or logical false if not. >> vec = 'EK127'; >> ischar(vec) ans =

Changing Case: The MATLAB has two functions which convert strings to all uppercase letters, or all lowercase, known as the upper and lower. >> mystring = 'AbCDEfgh';

Illustration of Set operations: For illustration, given the vectors as shown below: >> v1 = 2:6 v1 = 2  3  4  5  6 >> v2 = 1:2:7 v2 = 1  3  5  7

Intersect function and setdiff function: The intersect function rather than returns all the values which can be found in both of the input argument vectors. >> intersect(v

Example of modular program: In a modular program, there would be one main script which calls three separate functions to complete these tasks: A function to prompt an us

Algorithm for the function e: The algorithm for the function eoption is as shown: Use the menu function to show the 4 choices. Error-check (an error would take place

Example of file ploting data: As the other example, a data file called 'compsales.dat' stores the sales figures (in millions) for divisions in a company. Each line in the f

Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures