Get Help

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
- :
- Range variable - atavism

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-04-2018
12:11 AM

09-04-2018
12:11 AM

Range variable - atavism

What is a Range variable?

This is a variable, without which it was impossible to do someone in old-old versions of Mathcad (Mathcad 4 I think but not Prime). There was no programming and technology for QuickPlot in this versions. Now, we have programming and technology of QuickPlon. But we continue to use the range variable according to habit, for convenience. But this sometimes creates some problems (one example here). The range variable is similar to the vector and some Mathcad users try to apply to the range variable tools intended purely for the vector.

My question is this!

Can you show me one Mathcad sheet where we can not do anything without a range variable?

One little example:

Labels:

25 REPLIES 25

Highlighted
##

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

09-04-2018
06:19 PM

09-04-2018
06:19 PM

Re: Range variable

Your vector variant still depends on a range (the for-loop!)

Basically a range can and should be used just for three different tasks:

1) index the elements of a matrix or vector

2) define a range for plotting

3) in a program in the definition of a loop

Highlighted
##

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

09-05-2018
02:00 AM

09-05-2018
02:00 AM

Re: Range variable

>Your vector variant still depends on a range (the for-loop!)

Sorry, it was not a Range Variable but the programming construction For. See please

>Basically a range can and should be used just for three different tasks...

Sorry, can but not should...

A ask one more!

Show please one Mathcad sheet where we must use a Range variable!

Highlighted
##

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

09-05-2018
05:37 AM

09-05-2018
05:37 AM

Re: Range variable

> Sorry, can but not should...

Always use the tool and the method which is most clear, most easy, etc.

And if the best method is a range, you should use it.

Your method to create a vector sure is a way to do the task without ranges, but using a range on worksheet level or using a program with a for loop is simply the better and more clear way to achieve the task.

>

Show please one Mathcad sheet where we must use a Range variable!

Why?? Why should we try to avoid a range?

Highlighted
##

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

09-07-2018
02:48 AM

09-07-2018
02:48 AM

Re: Range variable

It's no problem to do a For loop without using a range, because For works with vectors too:

However a range shows much more clearly what is going on.

So I guess the conclusion is: A range is not necessary, but while it's there it's better to use it (properly).

Success!

Luc

Highlighted
##

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

09-05-2018
10:19 AM

09-05-2018
10:19 AM

Re: Range variable

How about the old (still working in Prime Express) matrix sequential calculator:

Highlighted
##

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

09-06-2018
01:31 AM

09-06-2018
01:31 AM

Re: Range variable

Yes, Fred, we should use range variable in Mathcad versions without programming tools - old Mathcads and Mathcad Express. But now it is not good to have in Mathcad sheet both: range vars and vectors. A range variable is an atavism.

A propos!

Can you use not i:=1..10 but i:=stack(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)?

Highlighted
##

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

09-06-2018
04:04 AM

09-06-2018
04:04 AM

Re: Range variable

There's a much simpler method to get that vector:

i:=matrix(9,1,max)+1

Success!

Luc

Highlighted
##

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

09-06-2018
07:02 AM

09-06-2018
07:02 AM

Re: Range variable

I believe that the matrix equation that uses the index and index -1 to develop the next value in the matrix would not work without a range variable index. If i is a vector, how do you address the next location in the solution matrix?

I would be happy to be proven wrong.

Highlighted
##

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

09-06-2018
03:00 PM

09-06-2018
03:00 PM

Re: Range variable

Smells like challenge!

You mean something like this?

Luc

Highlighted
##

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

09-07-2018
07:25 AM

09-07-2018
07:25 AM

Re: Range variable

VERY NICE!

I stand proven wrong! (I am a bit surprised that Express will allow recursion.)

Highlighted
##

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

09-07-2018
09:17 AM

09-07-2018
09:17 AM

Re: Range variable

That should be no surprise. Recursion is (at least, should be) a feature of a function. And definition of a function is (fortunately) still possible in Express, where programming isn't. So you can define a function, but you cannot use programming in the definition of a function; but the if() function is available in Express (again: in contrast to the 'if' programming construct).

Luc

Highlighted
##

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

09-08-2018
01:56 AM

09-08-2018
01:56 AM

Re: Range variable

There was a function **until** in old version Mathcad and we was able to create loops without **for** and **while** operators!

Highlighted
##

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

09-08-2018
09:21 AM

09-08-2018
09:21 AM

Re: Range variable

@ValeryOchkov wrote:

untilin old version Mathcad and we was able to create loops withoutforandwhileoperators!

**while** loops do not (necessarily) require a range variable. Both **while** and **until** test conditions and so can be constructed without a counting index.

Highlighted
##

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

09-09-2018
11:22 AM

09-09-2018
11:22 AM

Re: Range variable

Valery,

Can you show a working example with the until() function?

(Proper usage of that function where it operates as specified...)

Luc

Can you show a working example with the until() function?

(Proper usage of that function where it operates as specified...)

Luc

Highlighted
##

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

09-09-2018
12:40 PM

09-09-2018
12:40 PM

Re: Range variable

One picture from my old book - a bisection method of the root finding:

Highlighted

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

09-09-2018
01:34 PM

Highlighted
##

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

09-09-2018
01:29 PM

09-09-2018
01:29 PM

Re: Range variable

As it was explained to me **until** is the same as a while loop. The until loop tests at the end of the loop and the while loop tests at the start; so the until loop will execute at least once

Highlighted
##

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

09-09-2018
01:37 PM

09-09-2018
01:37 PM

Re: Range variable

I think until works in Prime Express! While - not!

Highlighted
##

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

09-09-2018
06:11 PM

09-09-2018
06:11 PM

Re: Range variable

Thanks Valery!

I was able to recreate your example sheet in Mathcad 11 (needs to be set to 'backwards compatibility', otherwise I get an 'Obsolete function' message).

The function until should work in Prime Express because it's a function AND it is not considered 'Premium'.

In contrast, 'while' is a programming construct, not a function, and programming is considered a Premium feature, so not available in Express.

However, I cannot show Prime (4) Express functionality using until, because I get the error message that 'until' is an unknown variable....

Luc

Highlighted
##

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

09-10-2018
01:48 AM

09-10-2018
01:48 AM

Re: Range variable

@LucMeekes wrote:

However, I cannot show Prime (4) Express functionality using until, because I get the error message that 'until' is an unknown variable....

Luc

Can you open in Prime (4) Express the file in attach?

Highlighted
##

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

09-10-2018
04:18 AM

09-10-2018
04:18 AM

Re: Range variable

Valery,

I can open the file in Prime Express 4, no problem. After opening it shows the (saved) results. But when I recalculate:

So it's NOT because it's a 'Premium' function, but it's simply unknown.

Luc

Fred, do you get the same?

Highlighted
##

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

09-10-2018
07:26 AM

09-10-2018
07:26 AM

Re: Range variable

@LucMeekes wrote:

Valery,

I can open the file in Prime Express 4, no problem. After opening it shows the (saved) results. But when I recalculate:

So it's NOT because it's a 'Premium' function, but it's simply unknown.

Luc

Fred, do you get the same?

Yes. I'm fairly sure that "until" had disappeared from Mathcad some time before version 15.

Highlighted
##

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

09-10-2018
07:40 AM

09-10-2018
07:40 AM

Re: Range variable

The function 'until()' was declared obsolete in Mathcad 11. However if you set 'backwards compatibilty' it is still usable.

I understand from Valery's contribution that it (again) works as intended in Mathcad 15 and in Prime (but not Express).

Luc

Highlighted
##

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

09-10-2018
02:21 AM

09-10-2018
02:21 AM

Re: Range variable

@FredKohlhepp wrote:

untilis the same as a while loop. The until loop tests at the end of the loop and the while loop tests at the start; so the until loop will execute at least once

We use the until loop only in one case, when the boolean variable that controls the loop takes value only after the first execution of the loop body. This cycle is not present in Mathcad and we must artificially set the value of this variable before entering the while loop.

But the universal loop in Mathcad is

Highlighted
##

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

09-13-2018
12:11 AM

09-13-2018
12:11 AM

Re: Range variable - atavism

See please one real problem when we use a Range Variable - not a Vector (one problem with Excel component in Mathcad Prime)

https://community.ptc.com/t5/PTC-Mathcad-Questions/MathCad-results-in-Excel/m-p/571089