Skip to main content
3-Newcomer
Nov 18, 2026 9:02 PM UTC
Question

Iterating with indices

I am trying to do a time-based analysis.

A very simplified version is 
 

This works for i=1, but massdot is not updated beyond that.

Is there a way to get this to iterate?
Is there a way to get this to iterate with MathCad Express?

Thanks!
 

    3 replies

    Werner_E
    25-Diamond I
    Nov 18, 2026 9:49 PM UTC

    As you can’t use programming, this could be a way to do it

    You cannot use mass[i in the second line yet, because the assignment does not occur until after the entire right-hand side has been evaluated.

    In the full version of Prime you could of course use programming an a for loop:

     

    Translate
    23-Emerald V
    Nov 18, 2026 11:04 PM UTC

    Small simplification, may speed it up when iterating over a large range:

    In addition I should think that 

    You'll see why when you plot the results.

    Success!
    Luc

    Translate
    Werner_E
    25-Diamond I
    Nov 18, 2026 11:28 PM UTC

    Just for fun (and not recommended because its quite inefficient and slow) here a version using recursive functions and the “if” function (which also works in Prime:

    Prime 12 file attached

    Not sure but maybe the undocumented ‘fold’ function (see here) could be used for a more efficient variant.

     

    If you have to use Prime Express you might be interested in LucMeekes collection

    Translate