Using the command num2str

3 ビュー (過去 30 日間)
Khalid Alsinan
Khalid Alsinan 2020 年 11 月 11 日
コメント済み: Ameer Hamza 2020 年 11 月 11 日
When I run:
num2str(5.7831e-04)
I get: '0.00057831'
How can I obtain '5.7831e-04' instead?

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 11 日
Use sprintf()
sprintf('%.4e', 5.7831e-04)
  3 件のコメント
Khalid Alsinan
Khalid Alsinan 2020 年 11 月 11 日
Never mind! Thank you so much Ameer!!
Ameer Hamza
Ameer Hamza 2020 年 11 月 11 日
Storing a number is not a matter of format. Inside memory, it will be saved as a double datatype with same bits. The format is only important if you want to print the number.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by