Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Vector oddity

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:25 AM

08-27-2014
09:25 AM

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.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:51 AM

08-27-2014
09:51 AM

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 4

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:27 AM

08-27-2014
09:27 AM

Re: Vector oddity

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:33 AM

08-27-2014
09:33 AM

Re: Vector oddity

Mike, that was on purpose.

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

Dan

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:36 AM

08-27-2014
09:36 AM

Re: Vector oddity

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-27-2014
09:51 AM

08-27-2014
09:51 AM

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.