Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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
Solved! Go to Solution.
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.
Mike, that was on purpose.
I don't understand why changing the right hand side without actually changing it gives a different answer.
Dan
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
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.