Question

using this array

Lure dueren suuj (COM 94 97 95 19 91 88 95 87 90 72 78 60 98 87 81 79 76 69 192 80 77 73 78 70 80 89 81 186 94 901 b. Find th

I need to create a user created function in Matlab that does the following

IL ill. Select New File by moving mouse to that option Click on Script in the pop up menu. Type firstplace.m in the highlight

I have this so far but I'm so lost

function fistplace for loopgr) x_firstplacemax (gr); for i=1:length (gr) if gr(i)<x_min x_min - gr (i): end -end NOWU fistpla

could you please make this with comments on what the codes do

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function firstplace_student = firstplace(gr)
   x_firstplace = 0; % intialize index of student with highest grade to 0
   x_sum = 0; %initialize student highest sum of grades to 0
   [rowx, colx] = size(gr); %find size of input
   for r = 1:rowx %for each student
       rowsum = sum(gr(r, :)); %find the sum of all grades in that row i.e for the student
       if rowsum >= x_sum % if the sum of row is greater than the current highest,
           x_sum = rowsum; %save the highest
           x_firstplace = r; %save the student number
       end
   end
   firstplace_student= x_firstplace; %assign highest student with highest sum of grades to output variable
end

Add a comment
Know the answer?
Add Answer to:
using this array I need to create a user created function in Matlab that does the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT