To print in two aligned columns in Matlab, you can use the fprintf
function with a formatSpec
that specifies the format of the output. Here's an example:
main.m99 chars4 lines
In the above example, data
is a row vector of numbers. The reshape
function is used to reshape the data into a two-row matrix. The formatSpec
string specifies that each element should take up 10 spaces, left-aligned with -
, and there should be a newline \n
after every two elements. The fprintf
function then prints the formatted output.
You can adjust the width of the columns and the number of elements in each column as needed by changing the formatSpec
string and the reshape
function.
gistlibby LogSnag