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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

3-Visitor

## Extracting values from a matrix in a program

Hi All-

I am attempting to model the first-order change of A --> B. The little programming loop below does the transformation of A to B in time steps of n just fine. The problem is I cannot view the A vs time data as is shown in the MathCAD document below.

I know there are many other ways to solve this simple system, but getting this little programming loop to solve the problem is my goal.

ACCEPTED SOLUTION

Accepted Solutions
25-Diamond I
(To:Caleb01)

6 REPLIES 6
23-Emerald II
(To:Caleb01)

@Caleb01 wrote:

Hi All-

I am attempting to model the first-order change of A --> B. The little programming loop below does the transformation of A to B in time steps of n just fine. The problem is I cannot view the A vs time data as is shown in the MathCAD document below.

I know there are many other ways to solve this simple system, but getting this little programming loop to solve the problem is my goal.

Hi Caleb,

The reason your program isn't giving the expected result is that you are storing arrays. You either need to write a function/program to flatten them or store the values more directly.   In this case, the latter option is the easier option.   Use stack or augment when you want to create flat arrays of values.

I've only got Prime Express, so can't use programming, but I hope the following should help point you in the right direction (the program may even work!).

Cheers,

Stuart

23-Emerald II
(To:StuartBruff)

Or you could play around with indexing the variables ... a bit messier.

Cheers,

Stuart

3-Visitor
(To:StuartBruff)

Hi Stuart,

Thanks for your help.  You were spot on with the stacking.  To say that I don't understand indexing and matrices fully would be an ocean of understatement.  Your programing loop works wonderfully.  See it in action below.  I really do thank you for your insight and gracious response.

Best,

Caleb

23-Emerald II
(To:Caleb01)
No worries, Caleb, glad it worked.

Is there a reason that you calculate v as a (nested) vector? It seems as though you're just using it as an intermediary to get the A and B vectors and then throw it away when you exit the program. It simplifies the program and makes it easier to read if you just update v at every iteration.

Cheers,

Stuart
25-Diamond I
(To:Caleb01)