Similar question to previous post, except it is a matrix.

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

cystleren
Posts: 6
Joined: Wed Oct 29, 2008 10:53 am

Similar question to previous post, except it is a matrix.

Postby cystleren » Wed Oct 29, 2008 2:25 pm

I have a matrix A , what i want to do is if each factor is greater than 65, then matrix B= (factor-65), else factor returns 0.

I tried to create a new matrix S full of 65(same dimension as matrix A) and using code
matrix new_A = (A>65)*(A-65)+(A<=65)*0
However, it returns a matrix full of 0(@recode can't be used in matrix calculations).
Thank you!!!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11408
Joined: Tue Sep 16, 2008 5:38 pm

Re: Similar question to previous post, except it is a matrix.

Postby EViews Gareth » Wed Oct 29, 2008 2:51 pm

When you say "factor" do you mean element?

If so, you can use a couple of for loops to loop through the matrix element by element:

Code: Select all

matrix new_a = a-65
for !i=1 to @rows(a)
for !j=1 to @columns(a)
if a(!i,!j)<=65 then
new_a(!i,!j) = 0
endif
next
next
Follow us on Twitter @IHSEViews

cystleren
Posts: 6
Joined: Wed Oct 29, 2008 10:53 am

Re: Similar question to previous post, except it is a matrix.

Postby cystleren » Thu Oct 30, 2008 8:22 am

Great thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 9 guests