Delimit a vector by decimal
古いコメントを表示
Hi,
After importing my data and delimiting by white space, I am left with two columns. For example, I am left with a matrix with a column of
1.2340 or similar numbers like 122.433
and a column of
233 or similar numbers
My problem is that the left column has to be split at the decimal into two separate numbers--but exactly how it appears. If the number on the right hand side of the decimal ends in a 0, I need to preserve it, as this isn't actually a decimal, but two identifying numbers stuck together with a decimal. Every solution I have tried thus far that has separated the numbers have dropped the 0. Any suggestions?
14 件のコメント
Azzi Abdelmalek
2013 年 10 月 22 日
Not clear
Mason
2013 年 10 月 22 日
Azzi Abdelmalek
2013 年 10 月 22 日
Have you imported those data as a char or as double?
Mason
2013 年 10 月 22 日
Azzi Abdelmalek
2013 年 10 月 22 日
Ok, but why one number is with 3 decimals and another with 4 decimals? It's not possible
Azzi Abdelmalek
2013 年 10 月 22 日
編集済み: Azzi Abdelmalek
2013 年 10 月 22 日
Check this
A=[1.233;22.330;540.3001]
The result
A =
1.2330
22.3300
540.3001
Azzi Abdelmalek
2013 年 10 月 22 日
It's better if you post a sample of your txt file
Mason
2013 年 10 月 22 日
Azzi Abdelmalek
2013 年 10 月 22 日
What is the difference between 1.30 and 1.300?
But you'll play h, e, double-hockey sticks separating them as doubles.
Import as cell array of strings then split on the character decimal, then convert those substrings to numeric. That way you'll keep the '330' example as the full substring to convert instead of just the numeric remainder.
Or, of course, fix the broken data encoding scheme in the generating process and export two columns of properly scaled values instead of the combination.
Mason
2013 年 10 月 22 日
Azzi Abdelmalek
2013 年 10 月 22 日
If you import 1.3 and 1.300 as double, the result is the same
Mason
2013 年 10 月 22 日
Mason
2013 年 10 月 22 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!