Skip to main content
1-Visitor
Aug 27, 2014 1:25 PM UTC
Solved

Vector oddity

Hi,

Please can someone tell me why the second vector (V2) is different to the first (V1) in the attached workbook.

Version: Mathcad 15.0

RichardJAnswer
19-Tanzanite
Aug 27, 2014 1:51 PM UTC

I don't know what you mean by "changing the right hand side without actually changing it". Either it is changed, or it isn't.

For the first vector you use the range variable a to index the vector. When a=1, it assigns that value to element 1 of the vector. When a=2, it assigns that value to element 2 of the vector. Etc.

For the second vector you also use the range variable a to index the vector, but now you are assigning the value of b to whatever element a indexes. So when a=1 it assigns the range variable b to element 1 of the vector. When a=2 it also assigns the range variable b to element 2 of the vector. Etc. Since each element of the vector is a range it displays them as NaN (not a number). If you evaluate v[1, you will see that you get a range. You can also select the displayed vector, go to "format", "results", and on the "Display options" tab check the box "expand nested arrays", and select "matrix" as the display style.

Incidentally, but very importantly, note that arrays in Mathcad start at index 0 by default, not 1.

4 replies

1-Visitor
Aug 27, 2014 1:27 PM UTC

Because you had typed V2[a instead of V2[b

Translate
Dan8881-VisitorAuthor
1-Visitor
Aug 27, 2014 1:33 PM UTC

Mike, that was on purpose.

I don't understand why changing the right hand side without actually changing it gives a different answer.

Dan

Translate
1-Visitor
Aug 27, 2014 1:36 PM UTC

Because you can't assign the range variable to the array index unless it is also on the right hand side of the equation.

Message was edited by: Mike Armstrong

Translate