Page 1 of 1

Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 7:37 am
by RDS
I have a matrix with 100 rows and 100 column: M(100,100).
I need to construct two matrices one with the odd rows and with the even rows: M_odd(50,50 and M_even(50,50)

I have extracted the raws using the following loop
for !i =1 to 100
rowvector r!i = @rowextract(M,!i)
next

How can I construct the two matrices with a loop in order to avoid to following manual approach?
EVEN rows
rowplace(M_even,r1,1)
rowplace(M_even,r3,2)
etc...

ODD rows
rowplace(M_odd,r2,1)
rowplace(M_odd,r4,2)
etc...

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 8:07 am
by EViews Gareth

Code: Select all

create u 10
matrix(100,100) m
rnd(m)

vector(50) v_odd
vector(50) v_even
for !i=1 to 50
   v_odd(!i) = !i*2-1
   v_even(!i) = !i*2
next

matrix m_odd = m.@row(v_odd)
matrix m_even = m.@row(v_even)

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 8:30 am
by RDS
I get the following error message

non numeric argment v_odd in "matrix m_odd = m.@row(v_odd)"

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 8:37 am
by EViews Gareth
Which version of EViews?

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 8:38 am
by RDS
Eviews 7.2

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 8:43 am
by EViews Gareth
You'll need EViews 8.

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 9:02 am
by RDS
do you have another suggestion which runs in Eviews 7.2?

Re: Constracting two matrices with odd and even rows

Posted: Wed Oct 23, 2013 9:08 am
by EViews Gareth
You'll have to do the rowplace in a loop.