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

How to assign variable value as per condition rule in Mathcad Prime 2.0?

ppandarkar-2
15-Moonstone

How to assign variable value as per condition rule in Mathcad Prime 2.0?

Hi...

As I want to assign variable values as per condition in Mathcad which have to continue for next calculation, I will explain detail by following example.

1.PNG

As per Above example, I have assign values for variable ss, pp and Shaft_Type, So I have different values if my Shaft_Type is 1 or 2 ( Shaft_Type value will comes from Creo).

and same values will be applicable to my rest of calculation i.e. if my Shaft_Type is 1 , ss=4 and pp=10, and if my Shaft_Type is 2. ss=5 and pp=12. and later on I want to do calculation by taking these ss and pp vaules.

So please can you help me.

Thanks,

Prashant Pandarkar

1 ACCEPTED SOLUTION

Accepted Solutions
lturek
4-Participant
(To:ppandarkar-2)

- You cannot change global variables from within a program. Your program has to return a value and you can asssign the output of the prpgram to a global variable.

- A program can only return one single value. If you need more values, you have to collect them in a vector and return that vector.

- You have defined a function "test". This is only a function definiton, nothing else. If you want it to DO something, you have to call that function and evaluate and/or assign to a variable.

As I only have Prime 3.0 and you use Prime 2.0 we cannot exchange worksheets. This is because P2 cannot read P3 work sheets and P3 cannot save in P2 format. Thats PTC's way to tell us, that we are better off not to use Prime for anything serious.

So here are two pictures. The first showing a way with a simple assignment (no function) and the second grabs your idea of introduicing a function test. In both cases I use a standad else (not an else if) so the routine covers ALL possible values for ST (this formal argument can be named as you like, it must not becessarily be shaftType but can) to avoid an error.

1)

2)

Regards, LT

View solution in original post

3 REPLIES 3
lturek
4-Participant
(To:ppandarkar-2)

- You cannot change global variables from within a program. Your program has to return a value and you can asssign the output of the prpgram to a global variable.

- A program can only return one single value. If you need more values, you have to collect them in a vector and return that vector.

- You have defined a function "test". This is only a function definiton, nothing else. If you want it to DO something, you have to call that function and evaluate and/or assign to a variable.

As I only have Prime 3.0 and you use Prime 2.0 we cannot exchange worksheets. This is because P2 cannot read P3 work sheets and P3 cannot save in P2 format. Thats PTC's way to tell us, that we are better off not to use Prime for anything serious.

So here are two pictures. The first showing a way with a simple assignment (no function) and the second grabs your idea of introduicing a function test. In both cases I use a standad else (not an else if) so the routine covers ALL possible values for ST (this formal argument can be named as you like, it must not becessarily be shaftType but can) to avoid an error.

1)

2)

Regards, LT

ppandarkar-2
15-Moonstone
(To:lturek)

Yes. it works for me.

Thanks a lot.

Regards,

Prashant Pandarkar

Here are a few alternative methods that you could use ... I'm using the Prime 3.1 trial and not sure which ones should work in Prime 2.0.

Stuart

Top Tags