Converting Alternative Scientific Notation to MATLAB
古いコメントを表示
I have a file with these example numbers I have imported as strings. I can't import as numbers because they come up as NaN.
-5.769-2
3.9984-2
4.568450
These are the 3 variations of numbers in the file
I want to convert these imported strings to MATLAB double, but I get NaN for the first 2 variations.
str2double('-5.769-2') = NaN
str2double('3.9984-2') = NaN
str2double('4.568450') = 4.568450
I want to get the following
-5.769-2 = -5.769e-2
3.9984-2 = 3.9984e-2
Thanks for your assistance.
4 件のコメント
James Tursa
2020 年 11 月 17 日
Is there always a space separating the numbers that are on the same line? Can you be more specific about how these numbers appear on the lines in the file? Free format? Fixed columns? Same number of values per line? Etc.
Stephen Biel
2020 年 11 月 17 日
James Tursa
2020 年 11 月 17 日
You haven't answered my question about spacing. Are the numbers right next to each other, each in 8 columns exactly? Or ...? Can you post a sample of the lines? This would affect how people would answer your question.
Stephen Biel
2020 年 11 月 17 日
編集済み: Stephen23
2020 年 11 月 18 日
採用された回答
その他の回答 (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!