Skip to main content
8-Gravel
February 11, 2025
Solved

Replace values in a matrix with minimums for ranges based on a separate same size matrix in Mathcad.

  • February 11, 2025
  • 2 replies
  • 965 views

This request is more fully explained in the attached file. The request is for a way to take two single column vectors or matrices that are effectively two columns of a table when augmented (i.e., namely matrix A and matrix B). The first matrix "A" has several rows that have repeated values. A function has been run to create a new matrix "C" that has removed the duplicate rows.

Please help to write a function that will create matrix "D" such that "D" contains the minimum values from the second matrix "B" pertaining to rows that had the same value in matrix A. Thus, matrix D ensures that removal of duplicate rows from A does not lose the minimum associated values in "B". I think the details in the attached Mathcad Prime 10 file will help clarify this request.   

Best answer by ttokoro

image.png

ttokoro_0-1739320040063.png

 

2 replies

ttokoro
21-Topaz I
ttokoro21-Topaz IAnswer
21-Topaz I
February 12, 2025

image.png

ttokoro_0-1739320040063.png

 

t.t.
8-Gravel
February 12, 2025

Thank you. Very much appreciated.

25-Diamond I
February 12, 2025

As an alternative here is an all-in-one utility function which creates the final matrix in one go - might come handy ...

Werner_E_0-1739321998713.png

 

 

8-Gravel
February 12, 2025

Thank you. This is also an excellent solution. I will use both this and the other solution posted in my calculation so that I can use one to check the other. Very much appreciated. Grateful for your help and yes, I am sure this will come in handy.  I also really appreciate the fact that you uploaded the Mathcad file.