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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Assign Max Values Between Range of Matrix

davidlimtw
8-Gravel

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

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:davidlimtw)

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

 

 

View solution in original post

7 REPLIES 7
Werner_E
25-Diamond I
(To:davidlimtw)

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.

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
20-Turquoise
(To:davidlimtw)

image.pngimage.png

Werner_E
25-Diamond I
(To:davidlimtw)

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

 

 

Thanks Werner, this actually works....

LucMeekes
23-Emerald III
(To:davidlimtw)

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

Thank Luc, this solved the calculation I needed.

Announcements

Top Tags