How to use str2double( ) In MATLAB
The str2double() function is used for the conversion of strings to double-precision values.
Syntax:
str2double(string)
Here, str2double(string) is used to convert the text in the specified string to double-precision values.
Example:
Matlab
% MATLAB code for regexp() demonstration % Initializing a cell array A = { 'gfg' ; 'gfg1.23GFG' ; '5gfg10' }; % Calling the regexp() function over the % above cell array to extract number part B = regexp(A, '\d+(\.)?(\d+)?' , 'match' ); % Calling the str2double() function to % convert the text to double-precision values out = str2double([B{:}]) |
Output:
out = 1.2300 5.0000 10.0000
How to extract numbers from cell array in MATLAB?
In this article, we are going to discuss the extraction of numbers from the cell array with the help of regexp(), str2double(), cat(), and isletter() functions.