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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

4-Participant

Plotting a picewise function on mathcad 8

Hello,

I am getting this error when trying to plot piecewise funtions. I've search trhough the coummity for may solutions but I  can't solve my problem at all.  Could you please help me?

I attatch the mdcx and a pdf of the function.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
23-Emerald II
(To:r_solsot09)

One cause of the problem is that not all cases are covered (eg, 0 s).  I'd have used an elseif statement rather than evaluating each condition.   In addition, I'd have also used an explicit range variable to handle t.

Stuarr

8 REPLIES 8
23-Emerald II
(To:r_solsot09)

One cause of the problem is that not all cases are covered (eg, 0 s).  I'd have used an elseif statement rather than evaluating each condition.   In addition, I'd have also used an explicit range variable to handle t.

Stuarr

4-Participant
(To:StuartBruff)

Exellent. This worked out for me. I was trying something similar, it seams I was missing 2Tsw/100 when defining t.

Many thanks Stuart

24-Ruby V
(To:r_solsot09)

Actually Prime isn't as good in dealing with units as we often would like it to be - especially when it comes to plotting.

Primes quickplot feature only works unitless.

One way (not preferred) is to make the values unitless:

The preferred way is, as Stuart already had shown, to define a range variable for plotting. You can delete the end values on the axis as Prime will chose them appropriately itself. This also enables you to chose different units like the "ms"  for the abscissa values in the following screenshot

24-Ruby V
(To:Werner_E)

Afterthought

Here is a simpler way of dealing with the periodicity of the signal

It might also make sense making delta, V.max and T arguments of the function

23-Emerald II
(To:Werner_E)

And if all you have is Express 7, or want to try for the daily obfuscation prize, ...

Stuart

4-Participant
(To:Werner_E)

Hi, Werner.

Thank you for you response. I've seen you've implemented 2*T/500, which made me think that the greater the number the more acurate the plot should be.  For example I compared 10 vs 1000 (In order to make it more obvious). That been said, it seems that I should always go for a greater value. Am I right?

24-Ruby V
(To:r_solsot09)

@r_solsot09 wrote:

Hi, Werner.

Thank you for you response. I've seen you've implemented 2*T/500, which made me think that the greater the number the more acurate the plot should be.

Actually I used T/500, not 2*T/500 but you are right that this affects plot accuracy.

The second number in a range also controls the stepwidth.

If you use a range defined as

t := a, a + (b-a)/n .. b

for plotting, that means that n+1 points (n intervals) are used for plotting.

So  in the file we have  a=0 and b=2*T   and choosing T/500 = (2*T)/1000 as second means that the plot consists of 1001 equally spaced points which are connected by straight lines. I decided this would suffice to make a nice rectangle signal and not a trapezoid 😉

You may add a "symbol" to the plot trace to let Prime display the points it uses (here with 20 intervals):

4-Participant
(To:Werner_E)

Thank you for the detailed explanation 😌 I appreciate your help so much.

Announcements
Top Tags