elect - % % L = length(stu); % R = stu(1:2:end); % if L==1...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function electedstudent = elect(student) f m = length(student); d = student(1:2:end); d if m==1 electedstudent = student; else if d(end)==student(end) student = [student(end) student(1:2:end-1)]; elect(student); else student = student(1:2:end); elect(student); end end e % % function elected_student = elect(stu) % % The input stu is a row-vector of distinct integers.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % % L = length(stu); % R = stu(1:2:end); % if L==1 % elected_student = stu % else % if R(end)==stu(end) % This means that the length is odd. % stu = [stu(end) stu(1:2:end-1)]; % elect(stu); % else % stu = stu(1:2:end); % elect(stu); % end % end...
View Full Document

Ask a homework question - tutors are online