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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Translate the entire conversation x

max-values from each row across multiple vectors

JJWK
2-Explorer

max-values from each row across multiple vectors

I am using Mathcad Express 10 to calculate the stress and deflection of components under a specific load case. To avoid having to create a copy of the calculation for each component, I want to perform the calculation using vectors and matrices simultaneously for all components and their values.
Unfortunately, I don't have access to the full version of Mathcad so I can't use any programming.

However, when I switch the calculation to vectors, a problem occurs that I cannot solve. I have created a minimal example, see attached file.


There are three vectors (v1 - v3) which all have the same length. The length of the vectors results from the number of different components to be calculated and is not fixed but can change. Therefore, the solution must work with any vector length.

JJWK_0-1743173809030.png

What I am trying to achieve: I need the maximum values of each line from the vectors for the calculation later on. The resulting vector then has the maximum value from all the first rows of the vectors in its row 1 and so on for the next rows. The picture below shows the desired result.

JJWK_1-1743173850724.png

 

To achieve this I have come up with the following solution:

  • I create the matrix M1 to "combine" the vectors.
    JJWK_2-1743173974336.png
  • Then I create the function v_max(v,n) to determine the maximum value of a given row of the matrix.
    JJWK_3-1743173999411.png
  • I create the variable m that contains the range that represents the row indices of the matrix in order to be able to apply the function v_max to the entire matrix.
    JJWK_4-1743174065751.png

 

The calculation of v_max(M1,m) produces the expected result: a vector with the max values of each row of the vectors v1 - v3. But: I cannot continue calculating with this result or assign it to a variable. Error: “This value must be an integer”.

JJWK_5-1743174119317.png


I understand that Mathcad expects an integer as an index here, but why can Mathcad create the result vector as described but not assign it to a variable or calculate with it?

 

If anyone has any other ideas on how to determine the respective max values from the vectors (Mathcad Express only), I would be very grateful for that too!

 

Thanks in advance for your help!

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:JJWK)

Simply add a vector index "m" when defining v.var

Werner_E_0-1743174587213.png

 

BTW, you may want to have a look at @LucMeekes  toolbox of functions for Prime Express Prime Express...A joke

 

View solution in original post

2 REPLIES 2
Werner_E
25-Diamond I
(To:JJWK)

Simply add a vector index "m" when defining v.var

Werner_E_0-1743174587213.png

 

BTW, you may want to have a look at @LucMeekes  toolbox of functions for Prime Express Prime Express...A joke

 

JJWK
2-Explorer
(To:Werner_E)

Many thanks for the quick solution, it's finally working!
And also for the reference to the toolbox, I'll have a look there straight away.

Announcements

Top Tags