Comparing matrix and integer

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Aaron
Posts: 11
Joined: Thu Nov 07, 2013 2:42 pm

Comparing matrix and integer

Unread post by Aaron »

Dear All,

I need to compare 1 by 1 matrix and an integer value.

com te = 10
com bandw0 = 2.6614*((a2*te).^0.2); *This bandw is defined as RECTANGULAR[REAL], but the dimension is 1 by 1.
if bandw0 .ge. te-2
com bandw = te-2
else com bandw = bandw0

The second line of this program gives me an error message of:
## SX27. Illegal Combination of Data Types for Operation

It seems not allowed to compare an integer and a matrix.
What do I need to do?

Thank you for your help.


Aaron
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Comparing matrix and integer

Unread post by TomDoan »

Is this always going to be a 1 x 1 "matrix"? If it is, why would you be doing it that way? Is A2 a VECTOR or a scalar? If it's a scalar, then you're making a mistake by using .^ instead of just ^ as that forces the result to be a 1 x 1 matrix when it's actually a scalar.

It looks like what you really want is

compute te=10
compute bandw=%min(2.6614*((a2*te)^0.2),te-2)
Aaron
Posts: 11
Joined: Thu Nov 07, 2013 2:42 pm

Re: Comparing matrix and integer

Unread post by Aaron »

Dear Tom,

Many thanks for your help. I resolved the issue in the following way:

com hhh = %scalar(2.6614*((a2*te).^0.2));dis hhh
com bandw = %min(hhh,te-2); dis bandw

sincerely,


Aaron
Post Reply