From: Matt J on
"ratnesh kumar" <iam_ratnesh(a)yahoo.co.in> wrote in message <hj7du9$mn4$1(a)fred.mathworks.com>...
>
> thanks for answering but the post is wrong sorryfor that.mine target is to make matrix like
> mat=
> 0 code1 code2 code3 code4 code5
> code1 2 2 2 2 2
> code2 2 1 2 2 2
> code3 2 2 2 2 2
> code4 2 2 2 1 2
> code5 2 2 2 2 2
> question is can i will put the names for rows and columns like as above.
> on command
> mat(2,:)
> ans is like
> code1 2 2 2 2 2
> ......?
=======================

I'm not sure what's changed since your first post, but the following is what I think you want:

>> headings={0 'code1' 'code2' 'code3' 'code4' 'code5'}

headings =

[0] 'code1' 'code2' 'code3' 'code4' 'code5'

>> Table=[headings;headings(2:end).',num2cell(mat)]

Table =

[ 0] 'code1' 'code2' 'code3' 'code4' 'code5'
'code1' [ 2] [ 2] [ 2] [ 2] [ 2]
'code2' [ 2] [ 1] [ 2] [ 2] [ 2]
'code3' [ 2] [ 2] [ 2] [ 2] [ 2]
'code4' [ 2] [ 2] [ 2] [ 1] [ 2]
'code5' [ 2] [ 2] [ 2] [ 2] [ 2]


And then you can certainly index particular rows if you want, for example,

>> Table(2,:)

ans =

'code1' [2] [2] [2] [2] [2]


Just realize that these are cell arrays and not matrices and have to be manipulated a little bit differently sometimes.