Skip to main content
8-Gravel
June 17, 2023
Solved

Assign Max Values Between Range of Matrix

  • June 17, 2023
  • 2 replies
  • 2315 views

Dear All,

 

I am trying to assign the back to the largest value matrix within the gap =6 back to the range, i.e. 1 to 6, 6 to 12 and 12 to 18 and so on .. What is a suitable program and looping to do compare and reassign the largest value back to the range of matrix.

davidlimtw_0-1686995717617.png

 

 

 

 

Best answer by Werner_E

Unfortunately you did not provide a specific example of the vector you expect as a result and you did not answer the question what to do if the number of rows of M is not a multiple of gap!

As far as I understood you expect a result vector of the same length as M.
I also assumed that the last sub-matrix may be of a smaller size than gap if the rows in M are not a multiple of gap.

So here is my approach.

Attached file in Prime 9 format

Werner_E_0-1687023829259.png

 

 

2 replies

25-Diamond I
June 17, 2023

Can you explain in more detail what you are trying to achieve?

A few examples (input values AND the vector you expect as output) could help.

Also cover the case what should happen if the number of rows in M is not a multiple of gap.

8-Gravel
June 17, 2023

Hi Werner,

 

Thanks for your reply. I am trying get the max value from M1 to M6, then M7 to M12 and so on, then reasign the maximum values within this range back to the range, for example, M1 to M6 = 0, 1, 2, 0, 2, 1, the maximum value is 2, therefore answer for M1 to M6 shall be 2.

ttokoro
21-Topaz I
21-Topaz I
June 17, 2023

image.pngimage.png

t.t.
23-Emerald IV
June 17, 2023

Assuming that your vector length is an integer number times the value of gap, this function could be what you're looking for:

LucMeekes_2-1687004055772.png

 

With this example vector:

LucMeekes_1-1687003681558.png

With various values of gap, results are:

LucMeekes_3-1687004078211.pngLucMeekes_4-1687004085169.png

Success!
Luc

8-Gravel
June 19, 2023

Thank Luc, this solved the calculation I needed.