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

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

NH_10132494
3-Visitor

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

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

2 REPLIES 2

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

 

Much appreciate the help Werner_E.  Thank you.

Announcements