4-Participant
December 2, 2022
Solved
Create specified size matrix from vector
- December 2, 2022
- 1 reply
- 1251 views
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:
- 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
- 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!




