matlab - how to find negative and positive number from a string? -


i've set of chemical reactions, , need read first number of each chemical. example, i've string as

reaction = '-1.0cdcl2(aq)  1.0cd++  2.0cl-'; 

i want find -1.0 of cdcl2(aq), 1.0 of cd++, , 2.0 of cl-.

textscan works here (assuming white-space delimiting reactants):

>> c = textscan(reaction,'%f%s') c =      [3x1 double]    {3x1 cell} >> c{1}' %' decimals not shown ans =     -1     1     2 >> c{2} ans =      'cdcl2(aq)'     'cd++'     'cl-' 

also assuming reaction starts number.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -