Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hi,
Why when plotting f2(t, Tf) does not look like f1(t)? The two functions are the same...
Solved! Go to Solution.
@Cornel wrote:
And the only solution for this is this (to define Tf above f2)?
NO!!
You simply have to use your function the way you had defined it - with two arguments!
As i already wrote, you were missing the second argument when you called your own function.
Here a an alternative function
Calling the "mod" function twice is necessary to deal correctly with negative t-values because the implemented "mod" function would return negative values for negative arguments.
Another alternative:
could also written as
@Cornel wrote:
Hi,
Why when plotting f2(t, Tf) does not look like f1(t)? The two functions are the same...
No, they aren't the same. When you CALL f2 from within f2 you are missing the second function argument!
And the only solution for this is this (to define Tf above f2)?
@Cornel wrote:
And the only solution for this is this (to define Tf above f2)?
NO!!
You simply have to use your function the way you had defined it - with two arguments!
As i already wrote, you were missing the second argument when you called your own function.
Here a an alternative function
Calling the "mod" function twice is necessary to deal correctly with negative t-values because the implemented "mod" function would return negative values for negative arguments.
Another alternative:
could also written as
@Werner_E wrote:
When you CALL f2 from within f2 you are missing the second function argument!
It's not strange this? I mean I was expected that I can call f2 within f2 with also other arguments, beside t, like f(t, Tf) or f(t, x1, x2, x3, ...)...
@Cornel wrote:
@Werner_E wrote:
When you CALL f2 from within f2 you are missing the second function argument!
It's not strange this? I
Not strange at all!
If you define a function with two arguments, you have to provide two arguments whenever you call your function.
I mean I was expected that I can call f2 within f2 with also other arguments, beside t,
Yes, thats exactly what happens. Once you call it with t-Tf instead of just t, the other time you call it with t+Tf instead of just t.
It would also be possible to provide different values (other than Tf) for the second argument, but this would not make much sense when you try to define this square wave signal.
like f(t, Tf) or f(t, x1, x2, x3, ...)...
????????????????????????
User-defined functions must be called with exactly the number of arguments for which they were defined.
There are a few built-in functions that may be called with fewer arguments, as some arguments are optional. Unfortunately, you cannot create such functions yourself and define default values for any omitted arguments.
But what you are asking for with your x1, x2,... would be a call with more arguments than specified in the definition. That would be nonsensical, if how would Prime know what to do with the surplus arguments?
Translated with DeepL.com (free version)
Ok Werner, I understood now, more after you posted your second reply showing where the missing part was located. Thank you.