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

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

Anonymous Functions: The anonymous function is a very easy, one-line function. The benefit of an anonymous function is that it does not have to be stored in an M-file. This ca

I have a vector of X, one for Y , one for x-direction velocity U and one for y-direction velocity V. they are at same size. How can I plot streamline of that flow? I follow all exa

Cross Product: The cross or outer product a × b of two vectors a and b is defined only whenever both a and b are the vectors in three-dimensional space, that means that they b

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?

Implementation of binary search: The binary search can be implemented as a recursive function. The recursive function below also implements this binary search algorithm. It re

Image Processing: The Images are represented as grids, or matrices, of picture elements (known as pixels). In MATLAB an image usually is represented as a matrix in which each

Passing Structures to Functions: The whole structure can be passed to a function, or separate fields can be passed. For illustration, here are the two distinct versions of a f

Finding sums and products: A very general application of a for loop is to compute sums and products. For illustration, rather than of just printing the integers 1 through 5, w