Page 1 of 1

Help with Variable comparison

Posted: Tue Jul 07, 2020 11:13 pm
by electron67
Hello, I thought it was an easy comparison, but comparing each variable with the others has been difficult and I got lost; I am trying to compare variables and know which is the one with the highest value; for example X1 = 25, X2 = 31, X3 = 45, X4 = 39, X5 = 40, X6 = 37, X7 = 29; how to find the correct data without so many comparisons between the variables.

Can someone help or guide me with this :?:

Thanks
Enrique

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 12:57 am
by mnf
Hi Enrique,

Can you post your code so far?

The easiest way to do this would be to have the variables as an array (X[7]) then you can use a loop to find the highest (or lowest) value

Martin

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 3:07 am
by electron67
Hi Martin,

This flowchart is what I think could be excluding variables until reaching the highest value, but I think it would be a huge program.

Enrique

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 5:19 am
by electron67
I am closer

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 5:20 am
by electron67
I am closer

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 6:33 am
by mnf
Try something like this:
maxima.fcfx
(8.39 KiB) Downloaded 250 times
Note that I have added a C line in Maxima macro that allows this to macro to work with any size data array - however it will not simulate - so I've just used a fixed count (and added a comment on what to change for real-world use)
There are alternate ways to do this - for example if measuring some data then keep a record of highest value received.

Note - toUpper$ convert a string to upper case.

Martin

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 4:16 pm
by electron67
Hello Martin,

Excellent !!! It works, the program is simple, I would never have done it using that method. . .

Thank You !!!
Enrique

Re: Help with Variable comparison

Posted: Wed Jul 08, 2020 6:17 pm
by mnf
Glad to hear you got things working....

Martin