Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
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:
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
>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!
> 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?
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
How about the old (still working in Prime Express) matrix sequential calculator:
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)?
There's a much simpler method to get that vector:
i:=matrix(9,1,max)+1
Success!
Luc
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.
Smells like challenge!
You mean something like this?
Luc
VERY NICE!
I stand proven wrong! (I am a bit surprised that Express will allow recursion.)
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
There was a function until in old version Mathcad and we was able to create loops without for and while operators!
@ValeryOchkov wrote:
There was a function until in old version Mathcad and we was able to create loops without for and while operators!
while loops do not (necessarily) require a range variable. Both while and until test conditions and so can be constructed without a counting index.
One picture from my old book - a bisection method of the root finding:
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
I think until works in Prime Express! While - not!
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
@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?
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?
@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.
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
@Fred_Kohlhepp wrote:
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
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
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