Skip to main content
1-Visitor
November 21, 2019
Question

If statement

  • November 21, 2019
  • 4 replies
  • 2323 views

Hello,

 

I solve a non linear system by making use of MathCaf and I store the results in a variable (let's call it "sotto").

There are some values of the parameters (a, b, c, d) for which there is not any solution of the system,  therefore

MathCAD returns an error message (see attachment).

 

I would like to add an "if statement " to monitor when the solution of the system does not exist.

 

For example, if the system does not have solutions, the variable SOL=0, otherwise SOL=1.

Is there a way (a built-in variable ?) that tells me that the system is impossible to be solved?

 

 

Thank you

Kate

4 replies

21-Topaz II
November 21, 2019

Hi,

please attach the worksheet (we can't dedicate ourselves to writing your file ... don't you think?).

23-Emerald IV
November 21, 2019

There's no built-in variable, like you suggest. But you can check for errors.

Something like:

LM_20191121_IfStatement.png

Success!
Luc

25-Diamond I
November 21, 2019

Can be simplified to

 

B3.PNG

21-Topaz II
November 21, 2019

Hi,

Solved this way, it's almost ok ......

Kate problem.jpg

25-Diamond I
November 21, 2019

If you don't like the idea to write a function with a,b,c,d as arguments but rather would like to just use the defined values in the sheet, the following should do the job as demanded.

If a solution was found the variable SOL is 1 and the other searched for variables have their appropriate values.

If the system could not be solved, SOL is 0 and the variables are set to NaN ("Not a value").

B4.PNG