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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Convert Nested Array to Matrix

Bartz87
1-Visitor

Convert Nested Array to Matrix

From:

nested to matrix.bmp

ACCEPTED SOLUTION

Accepted Solutions

8 REPLIES 8

na2m.png

Here's another approach ...

collab - nest to flat array 01.jpg

Even works in Prime 1.0

collab - nest to flat array 02.jpg

Stuart

Yes, we can have here only one loop for!

We have in Mathcad Prime a new operator returns a matrix row:

na2matrix.png

One additional quastion.

Can you convert a matrix into a vector (create a matrix2vector function) with one loop for?

I can do it in Mathcad 15 but not in Mathcad Prime.

Valery Ochkov wrote:

One additional quastion.

Can you convert a matrix into a vector (create a matrix2vector function) with one loop for?

I can do it in Mathcad 15 but not in Mathcad Prime.

Yes. My standard vec function does it with only loop (and uses recursion to flatten any nested elements), but I imagine this isn't the один дополнительный) вопрос that you really had in mind?

Stuart

collab - 12 May 27 - vec 01.jpg

One loop for without recursion:

max2vec.png

Valery Ochkov wrote:

One loop for without recursion:

max2vec.png

Ah, OK, so you wanted to turn a matrix into a nested vector where each nested array is one element of the original matrix?

It should work in Prime, but not as a pure evaluation. If you assign it to a variable, it should be fine.

Stuart

I see first time in Mathcad 15/Prime that var:=... var= and var:=...= is not equal:

rv2vec.png

Valery Ochkov wrote:

I see first time in Mathcad 15/Prime that var:=... var= and var:=...= is not equal:

An even bigger problem, and a far more frustrating one, is that whereas I can evaluate

vec(0,0,1..1) in Mathcad 11..15, I can't even enter a range definition (x,y..z) as an argument in Prime 1.0.

Stuart

Announcements

Top Tags