MATLAB Help

Images are sometimes not shown due to bandwidth/network issues. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

You are currently reading a thread in /sci/ - Science & Math

Thread images: 4

Anonymous

MATLAB Help 2015-11-09 19:23:11 Post No. 7649011

[Report] Image search: [iqdb] [SauceNao] [Google]

MATLAB Help 2015-11-09 19:23:11 Post No. 7649011

[Report] Image search: [iqdb] [SauceNao] [Google]

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.

gym1=[9.821

9.923

9.624

9.432

9.534

9.203]

gym2=[9.700

9.925

9.83

9.987

9.354

9.879]

>>

>>7649011

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.

>>

Lol MATLAB

>>

>>7649054

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.

>>

>>7649060

yeah fuck matlab, this shit isnt anything close to fun, plus the instructor is trash and the SI is about the same. Everything with this is so fucking vague all the time.

>>

>>7649064

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

if (gym1(i)>gmy2(i))

x_1=x_1+1;

elseif (gym1(i)>gmy2(i))

x_2=x_2+1;

>>

>>7649076

I meant

elseif (gym1(i)<gmy2(i))

for the second condition of course.

>>

>>7649011

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

>>

>>

>>

>>7649096

our answers solve the problem OP specified.

if OP left out details, that's not our problem

>>

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!

>>

>>

>>7649104

a good rule of thumb is that if you're using a for-loop in matlab you're doing something wrong

>>

m=numel(gym1)

win1=zeros(m);

n=1;

while n<=m

if gym1(n)<gym2(n)

win1(n)=1;

end

n=n+1;

end

>>

>>7649138

just no

>>

>>

non related to matlab, c# algo

gym1.Select((value, i) => value - gym2[i]);

Values = 0, tie

Values > 0, gym1 wins

Values < 0, gym2 wins

easy intersecting index loop

>>

NEVER USE LOOPS IN MATLAB UNLESS YOU REALLY HAVE TO.

>>

>>7650400

>find

>not just sum

fail

>>

>>7649282

>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.

Thread images: 4

Thread DB ID: 76947

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.

This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.

If a post contains personal/copyrighted/illegal content you can contact me at wtabusse@gmail.com with that post and thread number and it will be removed as soon as possible.