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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Create specified size matrix from vector

TG_10514568
4-Participant

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

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

 

TG_10514568
4-Participant
(To:LucMeekes)

That's perfect, thanks so much!

Announcements

Top Tags