cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Vector oddity

Dan888
1-Newbie

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

1 ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:Dan888)

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.

View solution in original post

4 REPLIES 4
MikeArmstrong
5-Regular Member
(To:Dan888)

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

Mike, that was on purpose.

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

Dan

MikeArmstrong
5-Regular Member
(To:Dan888)

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

RichardJ
19-Tanzanite
(To:Dan888)

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.

Top Tags