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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Multiple values for single variable

awibroe
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
Werner_E
25-Diamond I
(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.

So instead of

you would rather write

With long winded calculations this could be quite cumbersome, though

LucMeekes
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

awibroe
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

DJF
16-Pearl
16-Pearl
(To:awibroe)

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

2017-03-22_7-22-35.jpg

t

LucMeekes
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