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
how to create a symmetric matrix?
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: how to create a symmetric matrix?
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?
0s on the diagonal, (-1) above the diagonal and 1 below the diagonal? Surely that means it isn't symmetric?
-
tanghanpost
- Posts: 27
- Joined: Tue Dec 30, 2008 6:39 am
Re: how to create a symmetric matrix?
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
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
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: how to create a symmetric matrix?
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
Who is online
Users browsing this forum: No registered users and 1 guest
