Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Not sure if this question belongs in this form but I don't know where else to go. I'm trying to index a matrix and do a < comparison on it. Every time I try something like A[1] it says:

Error, a Vector is not valid lhs to < or <=.

Can anyone help?

EXAMPLE:

A:=<1,2,3>:

b:=A[2]:

if b < 2 then .....

share|improve this question
    
A matrix is a two-dimensional array of numbers. Why are you providing only one index? –  Henning Makholm Sep 30 '11 at 3:50
    
sorry. I reduce it down to a 1 dimensional 1x4 matrix (vector). –  NSjonas Sep 30 '11 at 4:04
2  
And what do you expect < to do on a vector? That's not usually defined. –  Henning Makholm Sep 30 '11 at 5:24
1  
What exactly did you feed Maple? If you don't show your exact input, none of us could be more helpful... –  J. M. Sep 30 '11 at 8:00
    
Adding to Henning's comment, you need to properly define < on vectors. For example, you can compare the n^th norms of vectors by norm(A, n). Or you could compare the two vectors component-wise as follow. C := zip((x,y) -> evalb(x < y), A, B); and then andmap(`=`, C, true); –  user2468 Oct 1 '11 at 18:30

1 Answer 1

up vote 1 down vote accepted

Which version of Maple are you using? For me, using Maple 12, the following works just fine:

A := <1,2,3>;

$$A := \begin{bmatrix}1 \\ 2 \\ 3\end{bmatrix}$$

b := A[2];

$$b := 2$$

is(b < 2);

$$false$$

is(b <= 2);

$$true$$

share|improve this answer
    
yea well thats what i was trying to do but for for some reason my if statement wouldn't work. give you credit anyways –  NSjonas Oct 4 '11 at 17:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.