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!