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

5-Regular Member

## A series order question

Hi all experts

Hope you could do me a favor.

How could i express the following series order with programing function?

Tks

Ton is the constant value and Toff(t) is variable by having different "duration" Ton, Ton+T1, Ton+T1+T2

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:KC_10577235)

You may try a recursive approach either using he if-function

or the if-statement

And here is a non-recursive approach which should be more efficient for larger values of n

We can get rid of the local variable Rlast but have to treat n=1 as a special case and so have to use an if-statement

We can also hide that if-statement using a boolean factor

5 REPLIES 5
24-Ruby V
(To:KC_10577235)

You may try a recursive approach either using he if-function

or the if-statement

And here is a non-recursive approach which should be more efficient for larger values of n

We can get rid of the local variable Rlast but have to treat n=1 as a special case and so have to use an if-statement

We can also hide that if-statement using a boolean factor

5-Regular Member
(To:Werner_E)

Hi Werner

Thank you for the help.

If i would have better understand the logical flow in the programming, is there any debug command for watching the progress of step by step? like pause and start function, tks.

24-Ruby V
(To:KC_10577235)

@KC_10577235 wrote:

Hi Werner

Thank you for the help.

If i would have better understand the logical flow in the programming, is there any debug command for watching the progress of step by step? like pause and start function, tks.

No, unlike real Mathcad (version 15 and below) Prime unfortunately does not offer any kind of the debugging facilities you demand.
You may throw in "return" statements at specific positions of interest and return a single variable or a vector of variable values which are of interest to examine, but its tedious to do so and not very flexible. Its not a substitute for real debugging/trace capabilities.

Another way you may help yourself rudimentary is to use WRITEPRN and APPENDPRN to explicitely write informations of interest (variable values, recursion depth, ...) to an external text file. Still not a step by step debugger, requires code modification by throwing in the file access commands but can be quite handy in some situations.

5-Regular Member
(To:Werner_E)

Hi Master Werner

How to reform the program below to array or vector forms?

e.g: T(3)=[T1, T2, T3]

Tks

24-Ruby V
(To:KC_10577235)

Quick and dirty without changing function T

And a bit more efficient using a modified function

Announcements