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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Periodic Functions, How define them?

jcoolman
3-Visitor

Periodic Functions, How define them?

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?

1 ACCEPTED SOLUTION

Accepted Solutions
rag
1-Newbie
1-Newbie
(To:jcoolman)

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

View solution in original post

7 REPLIES 7

starting place

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!

wayne
3-Visitor
(To:jcoolman)

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.

rag
1-Newbie
1-Newbie
(To:jcoolman)

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

Guest2
1-Newbie
(To:rag)

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.

Top Tags