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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Extracting values from a matrix in a program

Caleb01
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.

1 ACCEPTED SOLUTION

Accepted Solutions

How about this approach?

Werner_E_0-1589644875214.png

 

View solution in original post

6 REPLIES 6
StuartBruff
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!).

 

2020 05 15 I.png

 

Cheers,

 

Stuart

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

 

2020 05 15 J.png

 

Cheers,

 

Stuart

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

RateofChange.png

StuartBruff
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

How about this approach?

Werner_E_0-1589644875214.png

 

Clean and elegant! This is the result I had envisioned when I first started this little task.  I just didn't quite know how to get there.  Thank you.

Top Tags