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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

14-Alexandrite

## Multiple values for single variable

CAn anyone tell me if it is possible to have multiple values for a given worksheet? I.e. if I want to work on multiple problems in one worksheet can I assign different values to the same variable I.e very simply can I calculate one rectangle area L*W using L:5 and W:5 then a differing rectangle of L:10 and W:10 without having to define as L and L1 and W and W1?

Cheers

A

5 REPLIES 5
24-Ruby V
(To:awibroe)

Being able to turn a complete Mathcad sheet into a function is a long standing, unfulfilled wish.

The best you could do is to turn your calculations into a function.

you would rather write

With long winded calculations this could be quite cumbersome, though

23-Emerald III
(To:awibroe)

You can write a sheet that just uses W and L, but NOT defines them, and use W and L everywhere in the sheet.

In order to operate the sheet, and get the values of W and L defined, embed it as a referenced sheet inside another sheet where you define the numerical values for W and L before the reference, and retrieve the results after the reference.

Success!
Luc

14-Alexandrite
(To:awibroe)

Hi Chaps,

I think I may have made this seem more complex than needed. With a little experimentation I think I have sorted this myself.

If for example I were looking at a given problem per page of the worksheet you can use repeat values throughout. Any calculation seems to all upon the last definition.

i.e. If you define A: 5 and B: 5 on page one and then calculate A*B= you get 25 obviously. Then in the same worksheet below all of this if you type A:10 and B:10 and then again type A*B= you get 100. Essentially it seems that the driver is where in the sheet the calculation is positioned. You could have 10 differing definitions for A and B and then it is dependant as to which definition is to the left or above the calculation as to which set of values are used in the calculation.

Cheers,

Andy

16-Pearl
(To:awibroe)

Another approach that might be what you are after is using arrays (and vectorization!)

t

23-Emerald III
(To:awibroe)

And yet another approach is to just define W and L at the start of a sheet, use them at will. Then further down define W and L with different values and from then on use them again.

You must realise that variables get their values upon definition and retain those values until redefined.

So you can have a single worksheet with two values for a variable W, but not at the same 'time' (=location within the worksheet)!

Luc

Announcements
Top Tags