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

If statement

Visitor

If statement

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

5 REPLIES 5

Re: If statement

Hi,

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

Re: If statement

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

Something like:

LM_20191121_IfStatement.png

Success!
Luc

Re: If statement

Hi,

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

Kate problem.jpg

Re: If statement

Can be simplified to

 

B3.PNG

Re: If statement

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

Announcements