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
IS Functions in Matlab: There are many functions which are built into MATLAB which test whether or not something is true; these function names start with the word is. As these

Replacing a string - function strrep: The function strrep finds all the occurrences of a substring within the string, and substitutes them with a new substring. The order of a

Displaying the cell arrays: There are several techniques of displaying the cell arrays. The celldisp function shows all elements of the cell array:   >> celldisp(cellro

Replacing, Finding, and separating strings: There are numerous functions which find and replace the strings, or parts of strings, within the other strings and functions which

deblank function: The deblank function eliminates only trailing blanks from the string, not leading the blanks. The strtrim function will eliminate both the leading and traili

Function fieldnames - structure functions: The function fieldnames will return the names of the fields which are contained in the structure variable. >> pack_fields = fiel

Square Matrices: If a matrix has similar number of rows and columns, for illustration, if m == n, the matrix is square matrix. The definitions which follow in this part apply

Sound Files: The sound signal is an illustration of a continuous signal which is sampled to result in a discrete signal. In this situation, sound waves traveling through the a

Gauss Elimination: The Gauss elimination technique consists of:    Generating the augmented matrix [A b]    Applying EROs to augmented matrix to obtain an upper trian

Program to Counting in a while loop: The script initializes variable counter to 0. Then, in the while loop action, each and every time the user successfully enter a number, th