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일

1 개 추천

Use sprintf()
sprintf('%.4e', 5.7831e-04)

댓글 수: 3

Khalid Alsinan
Khalid Alsinan 2020년 11월 11일
Thanks Ameer, but I don't want to display it.. I just want to store it. Is there another way other than sprintf?
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

질문:

2020년 11월 11일

댓글:

2020년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by