Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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.
Solved! Go to Solution.
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
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
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:
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
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
And if all you have is Express 7, or want to try for the daily obfuscation prize, ...
Stuart
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?
@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):
Thank you for the detailed explanation 😌 I appreciate your help so much.