Converting to scientific notation in matlab

1,420 ビュー (過去 30 日間)
Arokia Bharat
Arokia Bharat 2022 年 6 月 20 日
編集済み: Arokia Bharat 2022 年 6 月 20 日
Hi Team,
Could anyone let me know how I can represent the below number
5000000
as 5*(10^6) or 5e^6
in matlab?
The reason is that everytime I have to count the number of zeros, I was wondering if there was an easier way.

採用された回答

John D'Errico
John D'Errico 2022 年 6 月 20 日
We are not a "team". We are just a number of people who act as complete volunteers, individually.
You cannot "represent" it that way. A number is just a number. In fact, it is stored in a binary form internally. So you cannot tell MATLAB to store it in some other form, perhaps as scientitfic notation.
You CAN make a copy of the number, stored in a variable as a text string. For example,
A = 500000
A = 500000
Now create a string version of the number.
B = sprintf('%10.f',A)
B = ' 500000'
So B is now a character string. Or you could have done this:
C = num2str(A)
C = '500000'
Or, if you want an explicitly scientific notation form...
D = sprintf('%10e',A)
D = '5.000000e+05'
Honestly, I don't think any of these ways are any easier to deal with for whatever are your purposes. But whatever floats your boat.
  1 件のコメント
Arokia Bharat
Arokia Bharat 2022 年 6 月 20 日
編集済み: Arokia Bharat 2022 年 6 月 20 日
Thank you so much !
this is exactly what I was looking for, although I understand its a string.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by