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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

## Range Variable Evaluation results in Error at Other Equations  6-Contributor

## Range Variable Evaluation results in Error at Other Equations

I am using Mathcad Prime 7.0 7.0.0.0

Range Variable Evaluation results in Error at Other Equations

Here are the errors that I faced
"This variable must be an integer".

A range variable is used to evaluate other equations.
When the range variable is evaluated, the other equations do not evaluate, for reason that "This variable must be an integer".
When the range variable is NOT evaluated, the other equations evaluate, as expected.

See attached screen shots of equations, one shows the variable evaluated, the other not evaluated.  By request, sample worksheet added.

Question: What am I not understanding about the evaluation, or the NOT evaluation of the range variable?
AND
Another question might ask if the variable can be evaluated as an integer so that subsequent equations will still evaluate.

Thanks.

MGM

1 ACCEPTED SOLUTION

Accepted Solutions  21-Topaz I
(To:Michael-Mills)

Hi Michael,

The problem is an equal sign after the definition of the range variable "i".

An undocumented feature of Prime is that if you define a range variable then use an equal sign in the definition it turns the range variable into a vector.

This is a problem if you then use the now defined vector to index a position in a vector. is OK as i is a range variable. is not OK as i is now a vector not a range variable.

If you want to see the value of the range variable on creation do this Cheers

Terry

7 REPLIES 7  24-Ruby II
(To:Michael-Mills)  6-Contributor  21-Topaz I
(To:Michael-Mills)

Hi Michael,

The problem is an equal sign after the definition of the range variable "i".

An undocumented feature of Prime is that if you define a range variable then use an equal sign in the definition it turns the range variable into a vector.

This is a problem if you then use the now defined vector to index a position in a vector. is OK as i is a range variable. is not OK as i is now a vector not a range variable.

If you want to see the value of the range variable on creation do this Cheers

Terry  6-Contributor
(To:terryhendicott)

Terry,

Outstanding!  If I could give you 2 kudos, I would.

I vaguely remember reading the condition and effect that you described, but I could not find it to check on myself.

I'm now wondering if there is a means to undo the vector effect?

As a test, I added the equal sign to the range variable and it presented the vector.  I then copied the the range variable down below, but without the equal sign.  With the restatement of the range variable i, equation for Kz evaluates as expected.

See the following and note that the range variable is vectorized with an "=" sign, thus the equation for Kz doesn't work, as previously shown. Next, the range variable is restated, and without the "=".

Thus, equation for Kz is evaluated as shown here.

Is there another way to undo or cancel the vector effect?

Thanks.

MGM  24-Ruby V
(To:Michael-Mills)

You mean a way to transform a vector into a range? No, none that I would be aware of and you would also run into problems if the vector elements are not equally spaced.

But why would you like to do so? Simply don't use the inline evaluation after the definition of the range.

If your goal is to display the range for whatever reason, simply define it and in an extra region beside evaluate it (see below).

Note that Prime (unfortunately) displays a range the very same way as a vector which sure adds to the confusion. BTW, as can also be read here in the forum now an then, inline evaluations can cause unexpected problems sometimes. So its a good behaviour to avoid them to be on the safe side.

Rather than writing you would write   23-Emerald II
(To:Michael-Mills)

@Michael-Mills wrote:

Is there another way to undo or cancel the vector effect?

Trite as it may seem, the easiest way to undo the effect is not to do it in the first place, or use the backspace key once you've checked the values.

I'm not aware of any feature (documented or otherwise) that will unconvert a range.  However, it is reasonably simple to do so if one doesn't mind that foulest of Anglo-Saxon swear words "work", As it happens, I have an allergic reaction to doing the same thing more than once if I can get a machine to do the repetition, so I normally use a function for that kind of thing. Stuart

Edited to add: Examples created in Mathcad Prime Express 7.0, but they should work in several other versions as well.  23-Emerald II
(To:StuartBruff)

Forgot to add the worksheet (Mathcad Prime Express 7).  It has some extra bits in.  Stuart 