I cant seem to figure this out, and I always overthink stuff when it comes to programming and MATLAB, but any help would be amazing.
Two Gymnasts are competing with each other.
How do I write a program that uses find to determine how many events each gymnast won.
I guess the vectors are something like the time they ran so the one with the lower number won? Just define to variables to denote the number of times each Gymnast won and the interate over the entries of the vectors and increase the variable of whoever has the lower entry.
Im not gonna write the code for you, because it´s your homework.
It is whoever has the highest score, I understand what you are saying, but how would I write that with the vectors? would i just be like vault1=find(gym1:1,gym2:2) ? I just dont understand how you write this piece.
The last time I had to write Matlab code was some time ago, so maybe theres an easier way to do this. As far as I remember you can just write something like
the number of positive numbers in gym1-gym2 is how many events gym1 won, the number of negative numbers is how many gym2 won
gym1_wins = sum(gym1 - gym2 > 0);
gym2_wins = sum(gym1 - gym2 < 0);
ties = sum(gym1 - gym2 == 0);
>not just using boolean comparisons
this is literally a 1loc question
I know it is a waste of time, You guys explained everything amazingly. I was just overthinking this way too fucking hard like I always do with programming stuff. Thankyou again, I really appreciate it!
>subtraction then comparison
>wtf are you doing?
Not that Anon, but what he's doing is similar to the comparto method in comparable interface and the compare method in comparator Interface.
His method is actually better because it builds a better fundamental understanding of comparing elements. Later on when comparing objects his method will work, and yours will not.