Hi how can we print a matrice directly with 10*10 order

I want to print a matrix of the form 1 to 10 in a row i.e.,
1,2,.....10;
2,........1;
...........
...........
...........
10........9;
Can we directly do it in matlab

4 Comments

Do you mean using a printer?
No I want print it on command window
What exactly do you want to do? What is "a matrix of the form 1 to 10" and what do the dots mean? Of course we can try to guess such details, but it is more efficient, if you tell this more exactly. Thanks.
I want to print a matrix having 10 rows and 10 columns with numbers 1 to 10 in a row and and same for column i.e., 1 to 10 numbers Thanks

Sign in to comment.

Answers (1)

Jan
Jan on 4 Jun 2013
Edited: Jan on 4 Jun 2013
Perhaps you want:
c = 1:10;
M = hankel(c, fliplr(c)); % [EDITED]
fmt = [repmat('%d,', 1, 9), '%d\n'];
fprintf(fmt, M); % Usually you'd need M', but not here

2 Comments

Exactly but only first is correct and all other rows are missing digit `1` Thanks!
Jan
Jan on 4 Jun 2013
Edited: Jan on 4 Jun 2013
@Krishna: This was a mistake in the hankel call. It's fixed now. See [EDITED]

Sign in to comment.

Tags

Asked:

on 29 May 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!