Page 1 of 1
how to create a symmetric matrix?
Posted: Fri May 07, 2010 2:15 am
by tanghanpost
hi,
i want to create a symmetric matrix,like this: the upper is (-1), the lower is 1, and the diagonal is 0, i only find the command: sym(n), if n=100,it's crazy to input the matrix by hand.
thanks!
Tanghan
Re: how to create a symmetric matrix?
Posted: Fri May 07, 2010 8:12 am
by EViews Gareth
I'm not quite sure I can visualise the sym you're trying to create.
0s on the diagonal, (-1) above the diagonal and 1 below the diagonal? Surely that means it isn't symmetric?
Re: how to create a symmetric matrix?
Posted: Fri May 07, 2010 6:37 pm
by tanghanpost
sorry,i mixed a mistake about it. i mean i want to create two matrix, one is symmetric, row=col=100, the diagonal=0, others=1. the second matrix is a simple matrix, row=100,col=100,the diagonal=0, but upper the diagonal is 1, lower the diagonal is (-1),
i find that the command sym(100) can create a symmetric matrix, but all cells=0, i don't know how to change it, or is there an other command to create matrix describe above?
thanks!
Tanghan
Re: how to create a symmetric matrix?
Posted: Fri May 07, 2010 7:13 pm
by EViews Gareth
Code: Select all
sym mat1 = abs(@identity(100)-1)
matrix mat2 = mat1
matrix mat2 = mat1
for !i=1 to 100
for !j=!i+1 to 100
mat2(!i,!j) = -1
next
next