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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Comparing two groups of values

Germán
8-Gravel

Comparing two groups of values

Dear community,

 

I turn to you once again hoping that with your generous assistance, we can resolve the following issue.

 

I want to compare two groups of values, M and N, both of which may have variable ranges, denoted by i and j respectively. The resulting group R should have the same range as M and should take the corresponding values from N, in this case, the value of Nj that is less than or equal to Mi.

 

I am using Mathcad Prime 9.0.0.0. and I have attempted to configure several programs to achieve this without complete success, but I believe I am unable to set it up with the correct syntax to achieve the desired result.

 

I am attaching an image for clarity, in case it may help. Thank you very much in advance for your support.

 

Germán

 

Captura de pantalla 2024-05-16 130100.png

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Germán)

You should also attach a worksheet so we have something to play with as retyping expression from a picture is boring.

 

Your description is absolutely unclear to me.

Wich element in N would be "corresponding" to which in M ?

When you talk about comparing M[i with N[j, which i and j you are talking about?

 

From your description I would have expected that the "2" in M would be replaced by the "1" an N as this the value in N which is "less than or equal to Mi.". You replaced it by a "3" which sure is not less than 2.

Or does the "less than or equal" refers to the index i and not the element value Mi ? But then ... why would the "3" in your example be replaced by a "3" again and not by the "6" which is in the corresponding position in N?

 

Your tasks sure needs more clarification concerning the algorithm you want to be applied. It also would help if you provide more than one example and attach a worksheet containing your examples.

 

EDIT: In case you made a mistake in your description and meant "greater than or equal" instead of "less than or equal", here is a possible approach:

Werner_E_0-1715878307112.png

Its assumed that the values in the second function argument "v" (actual argument is matrix N in the example) are sorted in ascending order!

 

View solution in original post

5 REPLIES 5
Werner_E
25-Diamond I
(To:Germán)

You should also attach a worksheet so we have something to play with as retyping expression from a picture is boring.

 

Your description is absolutely unclear to me.

Wich element in N would be "corresponding" to which in M ?

When you talk about comparing M[i with N[j, which i and j you are talking about?

 

From your description I would have expected that the "2" in M would be replaced by the "1" an N as this the value in N which is "less than or equal to Mi.". You replaced it by a "3" which sure is not less than 2.

Or does the "less than or equal" refers to the index i and not the element value Mi ? But then ... why would the "3" in your example be replaced by a "3" again and not by the "6" which is in the corresponding position in N?

 

Your tasks sure needs more clarification concerning the algorithm you want to be applied. It also would help if you provide more than one example and attach a worksheet containing your examples.

 

EDIT: In case you made a mistake in your description and meant "greater than or equal" instead of "less than or equal", here is a possible approach:

Werner_E_0-1715878307112.png

Its assumed that the values in the second function argument "v" (actual argument is matrix N in the example) are sorted in ascending order!

 

Dear Werner,

 

First of all, I apologize for the delay in my response. I was temporarily reassigned to different tasks at work and was unable to work with Mathcad.

 

Regarding your kind response, I must acknowledge that my explanation of the problem was not clear, and not attaching a file did not help clarify the issue. Sometimes, I am so immersed in a problem that I assume everyone understands it. Despite everything, after implementing it and conducting some tests, I can confirm that your solution works perfectly. I have attached a file with a brief explanation of the problem and your solution.

 

Once again, I greatly appreciate your help and reiterate my apologies.

 

Werner_E
25-Diamond I
(To:Germán)

Glad that my guess about what you need seems to have been correct.

I glanced at your file and I think that you could simplify the calculation at the start (assuming that N.e always would be positive):

Werner_E_0-1720441766067.png

 

Hi Werner! You are right, it is much simpler the way you show it. That was the method I came up with when I first started learning to use Mathcad and it worked, but the way you did it is more efficient. Thank you very much.

Hello @Germán

 

It looks like you have a response from a community member. If it helped you solve your question please mark the reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Announcements

Top Tags