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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

variable definition...

gLanzer
1-Visitor

variable definition...

hi,

is there a way to declare variiables that is not "globally" recognized?

say,

on a given "region"', say page 1, i want to use variables x,y,z and assign values to them,

then on page 2, i will still use variables x,y,z and assign them different values..

and there will be no connection between the values of x on page 1 of that on page 2.

---

so why i want to use the same variables? i'm solving a number of book problems that uses the same variable.

say, on Q1 and Q2, the question is to find the value of x given these parameters..

---

i can only achieve what i want by creating a new worksheet for another problem.

and i find having 10 problems and 10 seperate worksheets a little tedious..

thanks in advance

11 REPLIES 11

You can use two or more variables with same names but with different styles. They will be different variables.

In Mathcad, variables are not global, unless you use the global equals.

If you define x:= 1 the value of x from there on down is 1. If just below you define x:=2, then, the value of x above the second definition is still 1, but below it, x = 2.

So you can insert a number of problems, and just keep redefining your variables for each problem.

Mona

Example in attached image.

Mike

thanks mike,

you got my question right.

i thought that is not permissible, guess ím wrong

(i'm getting a warning "This expression redefines a previously defined variable" - which NOW i know that i can safely "ïgnore")

Nowel Lubi wrote:

thanks mike,

you got my question right.

i thought that is not permissible, guess ím wrong

(i'm getting a warning "This expression redefines a previously defined variable" - which NOW i know that i can safely "ïgnore")

No prolem.

You can turn the warnings off by clicking tools/preferences/warning and unchecking the variables box.

Mike

mzeftel
12-Amethyst
(To:gLanzer)

Nowel,


You can turn off the redefinition warnings, the squiggly green underline, by going to Tools > Preferences > Warnings tab. Uncheck the ones that you don't want to see.

Mona

FanCG
1-Visitor
(To:gLanzer)

I think it is safe. it is just a reminder. because what you want to do is redefine a predefined parameter name

In Mathcad, the argument to a function redefines itself at the point you re-range. If for instance you have ranged x:= -2,-1.999..2 and now you want to free the quick plot for the auto plot you declare x:= [it turns red] and the quick plot will plot in its default range -10..10 in 100 increments . Your question is not clear, not to say confusing.

MCADrange_1.gif

jmG

jean Giraud wrote:

Your question is not clear, not to say confusing.

Jean,

Look at my image, his question is simple - he just wants to re-define variables without adding alpha or numerical symbols.

Having said that the poster could just do as in the attached image.

Mike

I have replied more wisely as the very essence of the question made no sense. There are plenty of qs in the CD that do just what the collab wants. Variables are indefinitely redefinable. x1,y1,z1 ... x2, y2, z2 ... etc don't make sense either. Just care that if x, y, z are discretized, for the next use they have to be nulled, same thing with the any vector/array, i.e: null before reusing.

Jean

jean Giraud wrote:

Variables are indefinitely redefinable. x1,y1,z1 ... x2, y2, z2 ... etc don't make sense either.

Jean

Jean

Why does defining x,y,z for question 1 as x1,y1,z1 not make sense.

It clearly indicates to anyone reading that x1 is used in question 1.......

x2 is defined for question 2 and therefore used in question 2.

Mike

PS. After this page crashed the 'Use Recovered' function worked.

Announcements

Top Tags