Community Tip - You can change your system assigned username to something more personal in your community settings. X
I'm using MathCAD 15 in Windows 7 environment. I'm trying to create a vector using a range variable or at least that's what I think I'm doing. I thought I could set up a similar command sequence in user defined function as below:
But as you can see in my user defined function, MathCAD is not happy with me or range variables don't work the same way in a user defined function as they do in the regular environment.
Solved! Go to Solution.
StuartBruff wrote:
Andy Stevenson wrote:
I'm using MathCAD 15 in Windows 7 environment. I'm trying to create a vector using a range variable or at least that's what I think I'm doing. I thought I could set up a similar command sequence in user defined function as below:
But as you can see in my user defined function, MathCAD is not happy with me or range variables don't work the same way in a user defined function as they do in the regular environment.
Just to emphasize the point Luc is making, you cannot use range variables inside a loop in the way you want (and as seems reasonable). You have to use a for or while loop instead. You can still define a range variable to use, either inside a program or externally, but you have to handle them differently.
Oops, pressed a button too soon. I forgot to add an example of the normal use of a for loop and a non-looping recursive method.
Stuart
First off, the default start index for a vector is set by ORIGIN, which normally is 0. Apparently you've set it to 1 otherwise junk[0 would have been shown.
To create a vector in a program do:
This one is independent of the value of ORIGIN.
Success!
Luc
Andy Stevenson wrote:
I'm using MathCAD 15 in Windows 7 environment. I'm trying to create a vector using a range variable or at least that's what I think I'm doing. I thought I could set up a similar command sequence in user defined function as below:
But as you can see in my user defined function, MathCAD is not happy with me or range variables don't work the same way in a user defined function as they do in the regular environment.
Just to emphasize the point Luc is making, you cannot use range variables inside a loop in the way you want (and as seems reasonable). You have to use a for or while loop instead. You can still define a range variable to use, either inside a program or externally, but you have to handle them differently.
Stuart
StuartBruff wrote:
Andy Stevenson wrote:
I'm using MathCAD 15 in Windows 7 environment. I'm trying to create a vector using a range variable or at least that's what I think I'm doing. I thought I could set up a similar command sequence in user defined function as below:
But as you can see in my user defined function, MathCAD is not happy with me or range variables don't work the same way in a user defined function as they do in the regular environment.
Just to emphasize the point Luc is making, you cannot use range variables inside a loop in the way you want (and as seems reasonable). You have to use a for or while loop instead. You can still define a range variable to use, either inside a program or externally, but you have to handle them differently.
Oops, pressed a button too soon. I forgot to add an example of the normal use of a for loop and a non-looping recursive method.
Stuart
Thanks Guys. I knew had to get around it with just writing a brute force "for loop" in my user defined function. Just found it odd that the range variable method doesn't work inside a user defined function.
Stuart, your implementation isn't ORIGIN-proof...
{apart from the fact that Andy wanted steps of 0.1}
Luc
LucMeekes wrote:
Stuart, your implementation isn't ORIGIN-proof...
{apart from the fact that Andy wanted steps of 0.1}
Luc
Hi Luc,
Sorry, I want trying to make it origin-independent, just address the differences between range variable calypso inside and outside of a program. For that purpose, the scaling factor could have been anything.
Cheers,
Stuart