Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I want something like this:
f(t) = 1 if 2n.T < t <= (2n+1).T T is some constant
f(t) = 0 otherwise
but how can I tell to Mathcad 14 that n belongs to Z, the positive and negative integers ???
MC lets me definde a variable in finite intervals, n:=1.. 10, ok
It would be desirable something like n E Z
can you give me a real example to realize what tools of Mathcad I must use?
Solved! Go to Solution.
With the mod-function you are running into problems with neagtive values. The Mathcad modulo mod(x,m) unfortunately gives the result in the interval ]-m; m[ with the same sign as x. So mod (-13, 5) yields -3 and not +2, as we need here. You can use "mod(mod(t,T) + T, T)" as a workaround and stay in [0; m[.
For more complicated functions I would in the first step define an auxiliary function piecewise in one period, e.g. 0 to 2T in your case.
There are a lot of methods which comes to mind, e.g.
- using if-statements (nested, for more complex functions)
- using Mathcads programming facilities (looks best, in my opinion)
- use of the Heaviside function
- using boolean expressions
As a second step I would make this auxiliary function periodic by
- using the floor function, or by
- using a recursive definition
Of course you could combine the two steps in one function.
See the newly attached worksheet - hope it helps.
Regard
WR
Nice!
But it's not fully periodic, it fails at the origin.
Anyway, I turn this into a little more complicated issue, what if one wants:
f(t) = t.t if 2n.T < t <= (2n+1).T T is some constant
f(t) = T.(2T-t) if (2n+1)T < t <= (2n+2).T
how define n belongs to Z, infinite set of negative and positive integers.
Let us see your attempt!
Added a program to fred's example
(nice Fred, would never have thought of that)
You can modify the funtion to get other shapes as well.
With the mod-function you are running into problems with neagtive values. The Mathcad modulo mod(x,m) unfortunately gives the result in the interval ]-m; m[ with the same sign as x. So mod (-13, 5) yields -3 and not +2, as we need here. You can use "mod(mod(t,T) + T, T)" as a workaround and stay in [0; m[.
For more complicated functions I would in the first step define an auxiliary function piecewise in one period, e.g. 0 to 2T in your case.
There are a lot of methods which comes to mind, e.g.
- using if-statements (nested, for more complex functions)
- using Mathcads programming facilities (looks best, in my opinion)
- use of the Heaviside function
- using boolean expressions
As a second step I would make this auxiliary function periodic by
- using the floor function, or by
- using a recursive definition
Of course you could combine the two steps in one function.
See the newly attached worksheet - hope it helps.
Regard
WR
Nice work! Seems to be a somewhat comprehensive compilation.
Wonder if someone could come up with other elegant ways of graphing piecewise functions and making them periodic.
Grenn
Thanks winfrod for his brilliant class.