1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB num2str

  1. Aug 13, 2008 #1
    Hi all,
    I am converting a double to a string. But in the following case:
    -----------
    format long
    numnum=546.790;
    num=num2str(numnum)
    length(num)
    ---------------
    when 'numnum' is converted to a string, the command truncates the number by leaving off the last digit, the zero. Is there a way to keep the zero on there when converting to a string?
     
  2. jcsd
  3. Aug 15, 2008 #2

    marcusl

    User Avatar
    Science Advisor
    Gold Member

    Yes, specify the format as a floating point number
    num2str(numnum,'%3.3f')
    or use one of the other formats (scientific notation, etc.) listed in the Help manual. Check the Help entry for num2str and you'll see a clickable link to the format list.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: MATLAB num2str
  1. MATLAB num2str 2 (Replies: 6)

  2. Matlab concatenation (Replies: 2)

  3. Matlab and physics (Replies: 3)

  4. MATLAB problem (Replies: 1)

  5. MATLAB histogram (Replies: 3)

Loading...