Str2num function - string, MATLAB in Engineering

str2num function - String:

The function str2num does the opposite; it takes the string in which a number is stored and converts it to the type double:

>> num = str2num('123.456')

num =

  123.4560

 

When there is a string in which there are numbers split by blanks, then the str2num function will convert this to the vector of numbers (of the default type double).

For illustration,

>> mystr = '66 2 111';

>> numvec = str2num(mystr)

numvec =

66  2  111

>> sum(numvec)

ans =

179

 

 

Posted Date: 10/20/2012 5:43:28 AM | Location : United States







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

Write discussion on Str2num function - string
Your posts are moderated
Related Questions
. Generate the following signal, x(n)=1+cos((25*pi*n)/100),0 Compute the DTFT of x[n] for w=0:0.01:2*pi Plot the Real part, imaginary part, the amplitude and phas

Displaying expressions: The good-looking function will show such expressions by using exponents; for illustration, >> b = sym('x^2') b = x^2 >> pretty(b)

Illustration of Vectors of structures: In this illustration, the packages are vector which has three elements. It is shown as a column vector. Each and every element is a stru

Symbolic Variables and expressions: The MATLAB has a type known as sym for the symbolic variables and expressions; these work with strings. The illustration, to generate a sym

Example of image processing: The other illustration generates a 5 × 5 matrix of arbitrary integers in the range from 1 to the number of colors; the resultant image is as shown

Print from the structure: To print from the structure, a disp function will show either the whole structure or a field. >> disp(package) item_no: 123 cost: 19.99

Examine exponential function: The algorithm for the main script program is shown below:  Call a function eoption to show the menu and return the user's choice.  Loop

Basic mathematical operations: All the basic mathematical operations can be executed on symbolic expressions and variables (example, add, raise to a power, multiply, subtract,

Function used in binary search: The function below implements this binary search algorithm. It receives two arguments: the sorted vector and a key (on the other hand, the func

str2num function - String: The function str2num does the opposite; it takes the string in which a number is stored and converts it to the type double: >> num = str2num('123.