Skip to main content
3-Newcomer
October 24, 2024
Solved

This value must be a vector

  • October 24, 2024
  • 1 reply
  • 803 views

Hi I am new to Mathcad Prime and I'm trying to solve a kinematics problem, and I really need help. I want to multiply 3 nested arrays, but in step 4 I encountered the error "These arrays elements must be scalars. They cannot be vectors or matrices." I suspected it was because they are nested arrays, so I tried to convert the nested array H1 into a matrix with a code I found online and now I encountered the error "This value must be a vector,"

Any help is appreciated

Thank you

Best answer by Werner_E

Chances are that @StuartBruff  has a recursive utility function 'unnest' in his toolbox which can convert your nested matrices to regular 3x3 matrices,

But maybe its better to create H1,2,3 right from the start as 3x3 matrices:

 

Werner_E_0-1729770204013.png

 

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
October 24, 2024

Chances are that @StuartBruff  has a recursive utility function 'unnest' in his toolbox which can convert your nested matrices to regular 3x3 matrices,

But maybe its better to create H1,2,3 right from the start as 3x3 matrices:

 

Werner_E_0-1729770204013.png

 

23-Emerald V
October 24, 2024

@Werner_E wrote:

Chances are that @StuartBruff  has a recursive utility function 'unnest' in his toolbox which can convert your nested matrices to regular 3x3 matrices,

But maybe its better to create H1,2,3 right from the start as 3x3 matrices:


You rang?

 

Yes, I'm sure I do have a unnest function lying around, possibly several.  Although the problem looks specifically like it would be suited to one my block/unblock matrix functions. I shall add it to my list of things to look for.   It would be nice to have some means of looking inside an .mcdx worksheet and searching for terms in Windows Explorer or some such.

 

However, this case suggests that a tailored function that allows the best of both worlds.

 

2024 10 24 C.png

 

The replacement submatrix defined below is one that I find more generally useful than the built-in version.  After a decently short time, the brain gets used to the negative indices and it save a lot of typing and thinking when doing standard operations such as extracting complete rows or columns.  I believe that every matrix or vector function should have a vector/matrix counterpart, hence subvector.

 

2024 10 24 D.png

 

2024 10 24 E.png

 

Stuart