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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Plotting a picewise function on mathcad 8

r_solsot09
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.

screenshot.png

1 ACCEPTED SOLUTION

Accepted Solutions

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.

 

2022 04 04 a.png

 

Stuarr

 

View solution in original post

8 REPLIES 8

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.

 

2022 04 04 a.png

 

Stuarr

 

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

Many thanks Stuart

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:

Werner_E_0-1649077051273.png

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

Werner_E_1-1649077207156.png

 

 

Afterthought

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

Werner_E_0-1649078148866.png

 

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

Werner_E_0-1649085725008.png

 

StuartBruff
23-Emerald II
(To:Werner_E)

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

 

2022 04 05 b.png

 

Stuart

r_solsot09
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?

 

 image.png

 

 


@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):

Werner_E_0-1649152043270.png

 

 

r_solsot09
4-Participant
(To:Werner_E)

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

Top Tags