Skip to main content
1-Visitor
August 10, 2022
Solved

Assistance with operation comparing two column matrixes and producing result in one column matrix

  • August 10, 2022
  • 1 reply
  • 1331 views

I'm developing a MathCAD worksheet in Prime7 that works with data extracted from input matrices.  I cannot figure out how to take two variables, each of which comprise a 12 row x 1 col matrix, and compare each pair of values row by row to find the Maximum value, then spit that row's maximum value out into a new resulting column matrix.

 

My last attempt at a programming block with a simple concept is at the end of the worksheet, but instead of producing a column matrix only goes straight to the last iteration value and reports it.

 

Worksheet attached...thanks for any help!

Best answer by Werner_E

Thats how programs in Prime work - the return value is the last value assigned in the program. So in your case its the value of the last iteration.

If you want to collect the results you have to do it yourself by assigning the values in the loop:

Werner_E_0-1660151530104.png

You missed to attach the data Excel sheet, so I created random data vectors.

BTW, instead of "for i := 0 to 12" it would be more versatile to write "for i := ORIGIN to last(L[bltens)"

 

Another option would be to vectorize the max-function, but max is one of a few functions which cannot be vectorized. So you would have to create a used defined function which calls max and vectorize the call of this function:

Werner_E_1-1660151700850.png

 

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
August 10, 2022

Thats how programs in Prime work - the return value is the last value assigned in the program. So in your case its the value of the last iteration.

If you want to collect the results you have to do it yourself by assigning the values in the loop:

Werner_E_0-1660151530104.png

You missed to attach the data Excel sheet, so I created random data vectors.

BTW, instead of "for i := 0 to 12" it would be more versatile to write "for i := ORIGIN to last(L[bltens)"

 

Another option would be to vectorize the max-function, but max is one of a few functions which cannot be vectorized. So you would have to create a used defined function which calls max and vectorize the call of this function:

Werner_E_1-1660151700850.png

 

1-Visitor
August 10, 2022

Much appreciate the help Werner_E.  Thank you.