Loading data from document and isolating numbers.

Hi, I have to add to creating program a complicated database from other file with united numbers sometimes with no space between them. Which formula should I use to load from random line in data document, and isolate them to other calculations.
Example 1.543 345.1200 1.32399.0099.00 1.3399.00
Thank you.

댓글 수: 4

Jan
Jan 2013년 1월 9일
And what is the expected result? Is this 1.543, 345.12... or 1.5, 43, 34, 5.12, 00 ? Is there any chance that we can guess this reliably?
ZK
ZK 2013년 1월 9일
Yes of course is always the same value 99.00
So expected values are 1.543 345.1200 1.323 99.00 99.00 1.33 99.00
Unless you have some further information about the values of the numbers (e.g., always > 10) or the format (e.g., number of significant digits) you cannot retrieve the original numbers, because you can cut a chunk of digits at any positions other than those just before and after a . that would leave you with this single '.', which is not a number.
ZK
ZK 2013년 1월 9일
Thorsten like I said I have this value. It always looks like there is no space before 99.00

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 9일

0 개 추천

NumericLine = str2double( regexp( regexprep(TheLine, '99\.0', ' &'), '\s+', 'split') );

댓글 수: 2

ZK
ZK 2013년 1월 10일
Thank You, You were very helpful, I check it. Can I work with this formula when I have whole database loaded with fopen and fscanf with numbers characters and words?
You would need to have scanned the line as a string, so you might as well fgetl() instead of fscanf()

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

ZK
2013년 1월 9일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by