>> x = 14.021
>> num2str(x,'%4.5f')
I want to get this as a result:
0014.02100
But, MATLAB just answers me with:
14.02100
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use
sprintf. For example:Note that you don’t need to use
num2str.The first argument to
sprintfis the format specifier which describes how the resulting text should be displayed. The specifier begins with%, the leading0tellssprintfto pad the string with zeros. Loosely, the.5tells it to print five digits to the right of decimal point and theftells it we want to format it like a floating point number.