I have converted the string 04567 to double by using str2double function.But I got the output as 4567.But I need the output as 04567 .How can it be done?

조회 수: 1 (최근 30일)
I have converted the string 04567 to double by using str2double function.But I got the output as 4567.But I need the output as 04567 .How can it be done?

답변 (1개)

bio lim
bio lim 2015년 7월 11일
As a string, obviously you can have a leading zero. However, as you convert it to double or number, the leading numeral 0 is lost, because the numbers you converted, 4567 cannot start with 0.
  댓글 수: 4
Anushka
Anushka 2015년 7월 11일
편집: Walter Roberson 2015년 7월 11일
After converting from string to double I need the binary representation of the decimal format. But if the leading zero is omited then we would not get the correct binary representation.
Stephen23
Stephen23 2015년 7월 11일
편집: Stephen23 2015년 7월 11일
What exactly do you want "the binary representation" of:
  1. the string of characters '04567'
  2. the double 4567
  3. the vector of digits [0,4,5,6,7]
  4. something else?
In a sense all numbers have implicit leading and trailing zeros, even if these are not displayed in normal representations. But you really need to tell us what data "the correct binary representation" should be representing.

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by