How do you left or right justify matrix columns?
Show older comments
I have search through every help topic I could think of, and still can't find the commands to right or left justify the columns in a matrix. Can anyone help me?
Accepted Answer
More Answers (1)
Walter Roberson
on 24 Dec 2018
There is no MATLAB command to left or right justify command window output. If you want left or right justified command window output then you need to format the data as characters and display the characters. fprintf() could be used.
In particular for fprintf() and sprintf() when you use a field width (a number between the '%' and the '.' in the format specification) then by default the output is right justified within that width; however a negative number indicates left justification.
For example,
fprintf('XXXXX%10.3fXXXXX%-10.3fXXXXX\n', 3.14, 3.14);
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!