MATLAB Answers

Display matrix with row and column labels

15 views (last 30 days)
Hi all,
Is there a convenient way to display a matrix with row and column labels in the Matlab terminal? Something like this:
In the second row it will calculate x^2+4 also.
I know it is easily can be shown with the code:
x = 1:100;
table = [x; x.^2+4]
But it seems a bit nasty.
I will be happy if you will able to help. Thanks...

  0 Comments

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 10 Nov 2013
Use uitable
x=1:10
M=[x;x.^2+1]
r={'x' 'x^2+1'}
f=figure('position',[100 100 900 200])
t=uitable(f,'data',M,'rowname',r,'position',[0 0 850 200])

  3 Comments

Turgut
Turgut on 10 Nov 2013
Thanks for the answer it helped. I would just ask a question. What is the matrices stand for after 'position' in f and t?
Turgut
Turgut on 10 Nov 2013
And can I use the same solution to;
Azzi Abdelmalek
Azzi Abdelmalek on 10 Nov 2013
x=1:10
M=[x;x.^2+1]'
r={'x' 'x^2+1'}
f=figure('position',[400 400 300 500])
t=uitable(f,'data',M,'columnname',r,'position',[0 0 250 500])

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Translated by