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
Function used in sound files: The MATLAB has numerous other functions which let you read and play sound or audio files. In the audio files, sampled data for each audio channel

Use of built-in colormaps: MATLAB has built-in colormaps, it is also possible to generate others by using combinations of any colors. For illustration, the following generates

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

Matrix definitions: As we know the matrix can be thought of as a table of values in which there are both rows and columns. The most common form of a matrix A (that is sometime

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

Comparing strings: There are few functions which compare strings and return logical true when they are equivalent or logical false when not. The function strcmp compares the s

Illustration of Graphics properties: A particular property can also be exhibited, for illustration, to view the line width:     >> get(hl,'LineWidth')     ans =

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

Example Exit modular program: In the illustration below, the user  Chose the Limit; -   Whenever prompted for n, entered the two invalid values before finally ente

Finding a sting - function findstr: The function findstr receives two strings as input arguments. It finds all the occurrences of shorter string contained by the longer, and r