Sprintf: Right Justify
Posted on 2003-12-06
I am using spintf in Matlab to convert a matrix into a string to display it in an "edit text" box control. I convert one row at a time, and then concatenate them into a matrix. I use a horizontal tab '\t' at the end of each value converted in order that the columns stay aligned when the rows are concatenated into a matrix. The problem is that the values are all centered, whereas I would like to see them right-justified. I know that '-' can be used to left-justify the string, but I can't find any equivalent for right justification. Note, I cannot add spaces to the front of a converted string (to push it to the right), as the number of characters must be identical from one row to the next in order that they can be concatenated to form a matrix. Any thoughts?