{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW7s10_soln

# HW7s10_soln - pos1 = 3>> pos1 = pos_high_grade hws hws...

This preview shows pages 1–3. Sign up to view the full content.

function out = gavg( array ) len = length( array ); y = 0; for i = 1:len y = y + array( i ); end out = y/len; >> quizzes = gavg( [ 89 67 90 78 65 96 88 ] ) quizzes = 81.8571 >> hw = gavg( [ 9 10 8 7 7 9 10 8 8 9 6 8 10 ] ) hw = 8.3846 >> hws = [ 9 10 8 8 9 8 7 ]; >> total = gavg( [ 99 88 92 88 ] ) + gavg( hws ) total = 100.1786

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
function out = pos_high_grade( array ) len = length( array ); m = array( 1 ); loc = 1; %assume array has at least two elements for i = 2:len if ( array( i ) > m ) m = array(i); loc = i; end end out = loc; >> pos1 = pos_high_grade( [ 95.3 92.1 98.6 90.2 ] )
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pos1 = 3 >> pos1 = pos_high_grade( hws ) % hws is defined in problem 1 pos1 = 2 >> pos = pos_high_grade( [ 93.2 88.1 90.2 98.8 95.2 98.8 92.1 ]) pos = 4 function y = array_sort(array) len = length(array); for i = 1:len-1 for j = i+1:len if (array(i) < array(j)) temp = array(i); array(i) = array(j); array(j)= temp; end end end y = array; end >> y = array_sort( [ 95.3 92.1 98.6 90.2 99.1 87.3 93.7 88.2 ] ) y = 99.1000 98.6000 95.3000 93.7000 92.1000 90.2000 88.2000 87.3000 >> y = array_sort( [ 7 3 9 2 6 3 9 3 10 8 ] ) y = 10 9 9 8 7 6 3 3 3 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

HW7s10_soln - pos1 = 3>> pos1 = pos_high_grade hws hws...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online