Page 1 of 1

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

Posted: Wed Oct 29, 2008 2:25 pm
by cystleren
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!!!

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

Posted: Wed Oct 29, 2008 2:51 pm
by EViews Gareth
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

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

Posted: Thu Oct 30, 2008 8:22 am
by cystleren
Great thanks!