## 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, EViews Matt

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

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

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: 11875
Joined: Tue Sep 16, 2008 5:38 pm

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

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-65for !i=1 to @rows(a)for !j=1 to @columns(a)if a(!i,!j)<=65 thennew_a(!i,!j) = 0endifnext next`

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

Great thanks!