How to extract vectors from strings
古いコメントを表示
I have the following two strings from which I would like to extract the numbers in two respective vectors:
A = 'REAL 1.001 2.801 4.378 6.283 7.941 10.774 12.436 14.760 16.205 17.577 18.214 19.581 20.810 22.027' ;
B = '0.0 +3.188E-2 +8.918E-2 +1.394E-1 +2.000E-1 +2.528E-1 +3.430E-1 +3.959E-1 +4.698E-1 +5.159E-1 +5.595E-1 +5.798E-1 +6.233E-1 +6.625E-1 +7.012E-1' ;
However, str2num and str2double don't work well in these circumstances as in both cases text is contained within the string either in the first 'element' of the string vector, or as part of the scientific notation.
Also, I have tried sscanf(A, '%f'), however that suprisingly returns an empty vector.
Therefore, how can I extract these numbers from strings A and B ?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!