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

SOLVED
Highlighted
Gravel

## Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Dear all,

I need to plot multiple functions in a singe graph but ideally would like to plot each of them in their own range. For example,

x = 1 to 10, y(x) = sin(x)

x = 5 to 15 g(x) = cos(x)

x = 50 to 65 k(x) = (sin(x))^2

But if I try to plot all 3 graphs in a plot (x ranging from 1 to 100), I get 3 long curves (basically all 3 plots from 1 to 100). Is there any way I can curtail them ? I can do it using

plot_(x) := | plot(x)   if x > 1 (ctrl+&) x < 10

| NaN otherwise

But is there a faster / smarter way to do this ?

Also, does mathcad have a plot function command (for ex; like matlab) ? I also have a variable for the number of graphs I need to show in a plot (for example, it need not be 3 like shown above, but 4 or 5 or 2 depending on user input). Currently I am planning to put 20 (safe estimate) graphs and setting the values to "NaN" if the value does not exist (not input by user).

For example, if the user inputs 5 graphs (i = 5)

plot1_(x) := | plot1(x)   if x > 1 (ctrl+&) x < 10 (ctrl+&) 1 < i

| NaN otherwise

Doing this manually 20 times will automatically plot only the first 5 graphs, but it looks very amateurish and is there a smarter way to do it (less code) ?

Many thanks in advance,

Aravind.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

You could use a different range variable, for each function its own.

But I would stick to the approach with NaN. You could define an utility function to do this more comfortable.

See attached.

Unfortunately there is no plot function available in Mathcad.

There would be a little bit more elegant solutions available if you would not mind all plots being the same color (in fact it would be one single plot created by a function).

Furthermore we all wished Mathcad would allow for arrays of functions, which would make things easier, too.

15 REPLIES 15
Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Define xy, xg and xk respectively with their appropriate ranges and then plot y(xy) versus xy, g(xg) and k(xk) versus xk in the same plot.

Mathcad does not have a Plot function.
The maximum number of traces in a plot is 16. 20 will not work.

Success!
Luc

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Thanks a lot for the very prompt response LucMeekes,

I know how to add multiple tracers (Y axis) in a plot, but

How can I plot multiple X axis variables like xy, xg and xx in the same axis ? When I try to do so by using comma, my plot goes blank.

Could you please give me a quick sample of 2 plots of different ranges (xy and xg) like your example ?

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

You could use a different range variable, for each function its own.

But I would stick to the approach with NaN. You could define an utility function to do this more comfortable.

See attached.

Unfortunately there is no plot function available in Mathcad.

There would be a little bit more elegant solutions available if you would not mind all plots being the same color (in fact it would be one single plot created by a function).

Furthermore we all wished Mathcad would allow for arrays of functions, which would make things easier, too.

Highlighted

Like this:

Success!
Luc

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

I tried the same thing earlier and my graph was blank. I opened your attached mathcad file and the graph was blank !

Am I having some wrong settings or something ?

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Language problem? (Are you using a Mathcad in an edition other than English?)

Are you up to the letest mathcad 15 (M045 I guess?)

Luc

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Hi Werner !

Thanks a lot for the awesome answer. I would in-fact prefer if all the plots would be the same color. Could you please (sorry for the bother) give me a sample of how you could do so ? (Define a function which can plot overlapping curves in a single trace)

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

Yep, M045.

Weird. Werner_E also used a very similar code and I could see his graph (but not yours or mine).

Highlighted

## Re: Help: Regarding plotting multiple tracers in a single graph with different ranges (mathcad 15)

You've discovered why you need range variables:

Announcements