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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Create specified size matrix from vector

TG_10514568
2-Guest

Create specified size matrix from vector

I'd like to specify a matrix size and have it filled with elements from a vector. For this example, I have a vector containing state names and I want to have them fill a 7x4 matrix. I'm running into 2 issues with the attached sheet:

  1. I'm very rusty on programming and matrix operations, so the only way I've been able to fill a matrix at the size I want is to reference the specific elements of the vector. I'm sure there's a simpler way to do this using a loop but I haven't been able to figure it out
  2. If the vector changes size, I'd still like to be able to output a matrix with zeroes filling the rest of the nodes. Currently, if I set up a 7x4 matrix and the vector only contains 16 states, the output matrix errors out

Any help with this would be greatly appreciated! 

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:TG_10514568)

The function:

LucMeekes_0-1670006060690.png

should do the trick for you.

LucMeekes_1-1670006083696.png

LucMeekes_2-1670006094903.png

Success!
Luc

 

View solution in original post

2 REPLIES 2
LucMeekes
23-Emerald III
(To:TG_10514568)

The function:

LucMeekes_0-1670006060690.png

should do the trick for you.

LucMeekes_1-1670006083696.png

LucMeekes_2-1670006094903.png

Success!
Luc

 

That's perfect, thanks so much!

Top Tags