Can you use the 'format long' command in the 'fprintf' command?
Show older comments
I would like to have variable 'x' formated using the 'format long' command when it is printed using fprintf. However, I am unable to place it between the % and f values of ('%f',x) since 'format long' begins with an f. I have tried using '.15' between % and f, however, the output values are not aligned when the numbers infront of the decimal place increase (see below). Can 'format long' be used in fprintf? If not, how can I keep the numbers in front of the decimal place the same length (in this example, '08' for the last three entries)?
sqrt of a (x) error(e) iteration(s)
32.500000000000000 9.923e+02 1
17.234615384615385 2.330e+02 2
10.474036101145005 4.571e+01 3
8.292191785986859 4.760e+00 4
8.005147977880979 8.239e-02 5
8.000001655289593 2.648e-05 6
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!