How to compared 5 ints or floats at the same time?

Apr 28, 2007 at 4:32am

How to compared 5 ints or floats at the same time?

Hi,

If I got a sequence of numbers coming out from my video tracking output x (I only want to compare x output and ignore y output) and I want to compare every 5 of them …… In those 5 output numbers, I need to compare to each other and get the biggest one unless their difference are all under 5.

for example, there are 5 position tracking output in the first second: (2, 6, 4, 11, 13). In those 5 outputs, 13 is the biggest one so I only take 13 and continue to next 5 numbers. However, if the next 5 numbers are (5,4,7,6,8) then I will still keep 13 because in this set of numbers their difference are all not over 5 (even the biggest number 8 minus the most small number 4 is only 4).

I think what I can do is using counter to count 5 and get position x output in “somewhere” so that I can compare all of them at the same time. However, I don’t know which object can let me store 5 different output and compare them at the same time. At logic part, I also have problems of how to compare all those 5 numbers all together. I don’t know what is the best and most fast way to do the comparison. I would probably use “-”, “>” and “if”….

Yes, I am a newbie so I know this question is very simple to most of you. Please help me out. I appreciate anyone who give me an direction.

thank you so much

#31634
Apr 28, 2007 at 4:34am

Hi,

The internet connection in my house is very weird right now. Here I try to post again. Sorry if I post two times.

If I got a sequence of numbers coming out from my video tracking output x (I only want to compare x output and ignore y output) and I want to compare every 5 of them …… In those 5 output numbers, I need to compare to each other and get the biggest one unless their difference are all under 5.

for example, there are 5 position tracking output in the first second: (2, 6, 4, 11, 13). In those 5 outputs, 13 is the biggest one so I only take 13 and continue to next 5 numbers. However, if the next 5 numbers are (5,4,7,6,8) then I will still keep 13 because in this set of numbers their difference are all not over 5 (even the biggest number 8 minus the most small number 4 is only 4).

I think what I can do is using counter to count 5 and get position x output in “somewhere” so that I can compare all of them at the same time. However, I don’t know which object can let me store 5 different output and compare them at the same time. At logic part, I also have problems of how to compare all those 5 numbers all together. I don’t know what is the best and most fast way to do the comparison. I would probably use “-”, “>” and “if”….

Yes, I am a newbie so I know this question is very simple to most of you. Please help me out. I appreciate anyone who give me an direction.

thank you so much

#103052
Apr 28, 2007 at 10:01am

Hi,

you could use zl group, to get lists of 5 members, and then minimum and maximum objects, to get the extreme values. After that you compare them with an if object [if $i1 - $i2 > 5 then $i1 else bang], the bang is used to trigger the int out of a following int object….

Greetz

Gerald

#103053
Apr 28, 2007 at 10:35am

#103054
Apr 28, 2007 at 5:17pm

#P window setfont “Sans Serif” 9.;
#P flonum 29 340 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 168 43 85 196617 4 8 15 16 23 42;
#P newex 29 320 44 196617 f;
#P newex 29 299 29 196617 gate;
#P newex 95 272 27 196617 > 5.;
#P newex 108 228 29 196617 t b f;
#P newex 95 251 27 196617 – 0.;
#P message 131 164 52 196617 9999999;
#P message 95 164 19 196617 -1;
#P newex 108 206 81 196617 trough 999999.;
#P newex 63 206 42 196617 peak 0.;
#P newex 63 164 25 196617 iter;
#P newex 48 109 40 196617 t b l b;
#P message 114 43 52 196617 5 4 7 6 8;
#P message 48 43 64 196617 2 6 4 11 13;
#P connect 4 0 12 1;
#P connect 4 0 8 0;
#P connect 3 0 4 0;
#P connect 3 0 5 0;
#P connect 2 2 6 0;
#P connect 2 2 7 0;
#P connect 1 0 2 0;
#P connect 0 0 2 0;
#P connect 2 1 3 0;
#P connect 2 0 11 1;
#P connect 13 0 2 0;
#P connect 5 0 9 0;
#P connect 7 0 5 1;
#P connect 6 0 4 1;
#P connect 9 0 8 0;
#P connect 9 1 8 1;
#P connect 8 0 10 0;
#P fasten 10 0 11 0 100 294 34 294;
#P connect 11 0 12 0;
#P connect 12 0 14 0;
#P window clipboard copycount 15;

-C

Chris Muir | “There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue.” – Brian Eno

#103055
Apr 28, 2007 at 6:01pm

or look at expr!

On Apr 28, 2007, at 1:17 PM, Chris Muir wrote:

>
> #P window setfont “Sans Serif” 9.;
> #P flonum 29 340 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 168 43 85 196617 4 8 15 16 23 42;
> #P newex 29 320 44 196617 f;
> #P newex 29 299 29 196617 gate;
> #P newex 95 272 27 196617 > 5.;
> #P newex 108 228 29 196617 t b f;
> #P newex 95 251 27 196617 – 0.;
> #P message 131 164 52 196617 9999999;
> #P message 95 164 19 196617 -1;
> #P newex 108 206 81 196617 trough 999999.;
> #P newex 63 206 42 196617 peak 0.;
> #P newex 63 164 25 196617 iter;
> #P newex 48 109 40 196617 t b l b;
> #P message 114 43 52 196617 5 4 7 6 8;
> #P message 48 43 64 196617 2 6 4 11 13;
> #P connect 4 0 12 1;
> #P connect 4 0 8 0;
> #P connect 3 0 4 0;
> #P connect 3 0 5 0;
> #P connect 2 2 6 0;
> #P connect 2 2 7 0;
> #P connect 1 0 2 0;
> #P connect 0 0 2 0;
> #P connect 2 1 3 0;
> #P connect 2 0 11 1;
> #P connect 13 0 2 0;
> #P connect 5 0 9 0;
> #P connect 7 0 5 1;
> #P connect 6 0 4 1;
> #P connect 9 0 8 0;
> #P connect 9 1 8 1;
> #P connect 8 0 10 0;
> #P fasten 10 0 11 0 100 294 34 294;
> #P connect 11 0 12 0;
> #P connect 12 0 14 0;
> #P window clipboard copycount 15;
>
> -C
> —
> Chris Muir | “There are many futures and only one status
> quo.
> cbm@well.com | This is why conservatives mostly agree,
> http://www.xfade.com | and radicals always argue.” – Brian Eno

v a d e //

http://www.vade.info
abstrakt.vade.info

#103056
Apr 28, 2007 at 7:37pm

At 2:01 PM -0400 4/28/07, vade wrote:
>or look at expr!

I’d love to see an expr-based solution to this problem. Got one?

-C


Chris Muir | “There are many futures and only one status quo.
cbm@well.com | This is why conservatives mostly agree,
http://www.xfade.com | and radicals always argue.” – Brian Eno

#103057
Apr 28, 2007 at 8:16pm

On 28-apr-2007, at 6:32, UCDMSRA wrote:

>
> Hi,
>
> If I got a sequence of numbers coming out from my video tracking
> output x (I only want to compare x output and ignore y output) and
> I want to compare every 5 of them …… In those 5 output numbers,
> I need to compare to each other and get the biggest one unless
> their difference are all under 5.
>
> for example, there are 5 position tracking output in the first
> second: (2, 6, 4, 11, 13). In those 5 outputs, 13 is the biggest
> one so I only take 13 and continue to next 5 numbers. However, if
> the next 5 numbers are (5,4,7,6,8) then I will still keep 13
> because in this set of numbers their difference are all not over 5
> (even the biggest number 8 minus the most small number 4 is only 4).
>
> I think what I can do is using counter to count 5 and get position
> x output in “somewhere” so that I can compare all of them at the
> same time. However, I don’t know which object can let me store 5
> different output and compare them at the same time. At logic part,
> I also have problems of how to compare all those 5 numbers all
> together. I don’t know what is the best and most fast way to do the
> comparison. I would probably use “-”, “>” and “if”….
>
> Yes, I am a newbie so I know this question is very simple to most
> of you. Please help me out. I appreciate anyone who give me an
> direction.
>
> thank you so much
>

how about sorting the list of 5 numbers using Lsort (from the
indispensable Lobjects by peter elsea),
substracting the first element from the last,
and if that is over 5, then you replace the value you kept with the
last element

HtH
-jennek

#103058
Apr 28, 2007 at 9:05pm

it looks like it’s a contest…
this one is nearly an expr-based solution :)

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 16 207 70 9109513 print maximum;
#P newex 16 180 27 9109513 f;
#P newex 16 142 295 9109513 if ($f1-$f2)>5 then $f1 else out2 bang;
#P newex 16 113 281 9109513 expr
max(max((max($f1\,$f2))\,(max($f3\,$f4)))\,(max($f4\,$f5)));
#P newex 301 113 266 9109513 expr
min(min((min($f1\,$f2))\,(min($f3\,$f4)))\,(min($f4\,$f5)));
#P newex 16 80 295 9109513 t l l;
#P message 181 41 45 9109513 1 2 3 4 5;
#P message 16 41 65 9109513 2 34 21 22 47;
#P message 91 41 80 9109513 27. 12. 84. 35. 3.;
#P connect 7 0 8 0;
#P fasten 6 1 7 0 306 172 21 172;
#P connect 3 1 4 0;
#P connect 3 0 5 0;
#P connect 6 0 7 0;
#P connect 5 0 6 0;
#P connect 4 0 6 1;
#P connect 2 0 3 0;
#P connect 1 0 3 0;
#P connect 0 0 3 0;
#P window clipboard copycount 9;

#103059
Apr 29, 2007 at 2:48am

Hi,

Thank you all. They are all working fine. I use zl to trigger a sequence of number and the result is all what I expect.

thank you guys again.

#103060
Apr 29, 2007 at 3:13am

max(max((max($f1\,$f2))\,(max($f3\,$f4)))\,(max($f4\,$f5)));
> #P newex 301 113 266 9109513 expr
> min(min((min($f1\,$f2))\,(min($f3\,$f4)))\,(min($f4\,$f5)));

Would you please tell me that’s your logic expr really means? I just play around with it and I don’t really know that is “” and “
,” really do in this expr part.

thanks

#103061
Apr 29, 2007 at 8:31pm

On 4/28/07, UCDMSRA wrote:
>
>
> Would you please tell me that’s your logic expr really means? I just play
> around with it and I don’t really know that is “” and “
> ,” really do in this expr part.
>
> thanks
>

The backslash is used for special characters not to be interpreted as
special characters (tutorial 25).
In the example I gave you, the max (and min) functions in expr need 2
arguments, separated by a comma. You have to write it , or it does not work
(because comma is a special character).

expr max($i1,$i2) determines the maximum between i1 and i2.

expr max((max($i1,$i2)),(max($i3,$i4))) determines the maximum of the
maximum of i1 and i2 and the maximum of i3 and i4 (!!!!!), and so on…

For further infos about expr, have a look at tutorials 38, 48, 50.
Best.

#103062

You must be logged in to reply to this topic.