Adding space/symbol to the readed line.
이전 댓글 표시
Hi.
I had readed line of numbers as a char, like this: 2.450333.000 2.450333.000 5.100 1.230 1.210333.000 333.000 7.87
I would like to add spaces between the numbers to separate them. Fuction can add a space before all occuring numbers. It isn't importent how many space will be before the number, but that every number must be separately.
I was using B = regexprep(A, '333(\w*).000', ' 333.000 ') but when puted together numbers will change what can happen someday, it won't work. Can You suggest me another, better idea?
Thank You.
댓글 수: 4
Walter Roberson
2013년 1월 11일
In a previous question http://www.mathworks.co.uk/matlabcentral/answers/58333-loading-data-from-document-and-isolating-numbers you said that the number that needs to be split at is always 99 . Now it is 333, and might change. If you want the general solution to this you need to indicate how to recognize the break between numbers. For example, is it the case that the previous numbers will always have three digits after the decimal place? (If so then 7.87 fails that pattern.)
Cedric
2013년 1월 11일
In the line that you give at the top of your question, you already inserted spaces actually (?) Do you want to match a pattern (here '333' + whatever + '000') and insert one space directly after each match, or is it simpler than pattern matching (e.g. because the format is more regular that what you get with '\w*')? In your example, where did spaces in ' 5.100 1.230 ' come from? Are they already there or do you have to add them as well (I'm asking as they don't match your pattern)?
ZK
2013년 1월 11일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!