Page 1 of 1

Comparing matrix and integer

Posted: Fri Jan 17, 2014 2:27 pm
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

Re: Comparing matrix and integer

Posted: Fri Jan 17, 2014 3:10 pm
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)

Re: Comparing matrix and integer

Posted: Tue Jan 21, 2014 3:32 pm
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