yode
yode

Reputation: 643

How to show a one column matrix with muilt-column

If a matrix just have single column,the matlab will waste many space to show it,like this

Of course,sometime the function reshape can help a lot.But when the number of element is a prime number,the reshape doesn't work anymore.If I'm in Mathemtica I can solve this problem like

Is there any elegant method for this question in matlab?

Upvotes: 3

Views: 76

Answers (1)

rahnema1
rahnema1

Reputation: 15837

Using sprintf you can print the array row-wise:

disp(sprintf([repmat('%d\t',1,4) '\n'], (1:17).'))

Result :

1       2       3       4
5       6       7       8
9       10      11      12
13      14      15      16
17  

Upvotes: 2

Related Questions