Skip to main content
1-Visitor
Sep 18, 2014 8:10 AM UTC
Solved

Mathcad Plot with an if-statement?

Hi,

First time posting on these forums, been reading around for a couple of years though.

I would like to create a plot of 4 functions (let's say it's different pressures depending on a variable, h). I've done this in the appended example.

However, I would now like to plot only 2 of the functions if a variable, say "condition", is =1.

How can I do this?

I have tried adding an "if" statement on the y-axis of the plot itself, like this:

----

f.1(h) if condition=1

----

, but I get a critical error when doing that, and the plot goes blank.

I'm using MathCad 15.

Any suggestions are appreciated,

Thank you,

Hampus

RichardJAnswer
19-Tanzanite
Sep 18, 2014 9:57 AM UTC

NaN (non a number) is very useful when you want something to not show on a plot. It works for either entire plots, or individual points.

8 replies

RichardJ19-TanzaniteAnswer
19-Tanzanite
Sep 18, 2014 9:57 AM UTC

NaN (non a number) is very useful when you want something to not show on a plot. It works for either entire plots, or individual points.

Translate
1-Visitor
Sep 18, 2014 10:38 AM UTC

Richard,

Thank you, that worked perfectly!

Translate
Werner_E
25-Diamond I
Sep 24, 2014 9:37 PM UTC

Depeding on your needs it might be convenient to use a wrapper function based on Richards solution.

See attached.

Translate
1-Visitor
Sep 25, 2014 6:36 AM UTC

Nifty! That's a keeper, thanks

Translate