Skip to main content
8-Gravel
Jun 17, 2023 9:56 AM UTC
Solved

Assign Max Values Between Range of Matrix

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

 

 

 

 

Werner_E
Werner_EAnswer
25-Diamond I
Jun 17, 2023 5:23 PM UTC

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

 

 

7 replies

Werner_E
25-Diamond I
Jun 17, 2023 10:50 AM UTC

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.

Translate
8-Gravel
Jun 17, 2023 10:59 AM UTC

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.

Translate
ttokoro
21-Topaz I
Jun 17, 2023 11:30 AM UTC

image.pngimage.png

Translate
t.t.
23-Emerald V
Jun 17, 2023 12:11 PM UTC

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

Translate
8-Gravel
Jun 19, 2023 9:43 AM UTC

Thank Luc, this solved the calculation I needed.

Translate