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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Set variable array to add number

dsochor
5-Regular Member

Set variable array to add number

In the attached Mathcad Prime worksheet I am attempting to create variables L sub 1 through 4 where each value of L start at 5ft and adds a distance to it based on it's array value of L. This seems trivial, what am I missing in the attached?

1 ACCEPTED SOLUTION

Accepted Solutions

Don't use inline evaluation after defining the range variable i. Delete the = after definition and if you want to see what you have created, use i=... in a separate region.

Using the inline eval as you did converts the range i into a vector and you can't use vector elements to index another vector L. Its an undocumented dirty trick to quickly turn a range into a vector.

View solution in original post

3 REPLIES 3

Don't use inline evaluation after defining the range variable i. Delete the = after definition and if you want to see what you have created, use i=... in a separate region.

Using the inline eval as you did converts the range i into a vector and you can't use vector elements to index another vector L. Its an undocumented dirty trick to quickly turn a range into a vector.

dsochor
5-Regular Member
(To:dsochor)

Thank You Werner, is there a way to turn a vector back into a range variable (not that I have an example where I would want to do this, just curious).

Daniel Sochor wrote:

Thank You Werner, is there a way to turn a vector back into a range variable (not that I have an example where I would want to do this, just curious).

No and this would not make much sense as the values of a range are equally spaced while the elements of a vector could be anything you like. So conversion would have to fail most of the times.

But it sure is very easy to write a very small function to convert a vector to a range by just using the first, second and last element of that vector:

It sure is a design error that ranges and vectors look perfectly alike in Prime. This can be very confusing,

Top Tags