function [odd even] = OddEvenlnd(b) %replace the line below with code to assign
ID: 3788185 • Letter: F
Question
function [odd even] = OddEvenlnd(b) %replace the line below with code to assign to variable odd the contents in the odd indices of input variable b b = [8 -3 0 7 -6 -3 1 8 7 2]; odd = b([1, 3, 5, 7, 9]); %replace the line below with code to assign to variable even the contents in the even indices of input variable b even = b([2, 4, 6, 8, 10]); end Pass b = [8 -3 0 7 -6 -3 1 8 7 -2]; odd = [8 0 -6 1 7]; even = [-3 7 -3 8 -2]; [o e] = oddEvenInd(b); assert(isequal([o e], [odd even])] Fail b = [1 2 3 4 5 6 7 8 9 10]; [o e] = oddEvenInd(b); assert(isequal([o e], [odd even])]Explanation / Answer
function [odd even] = OddEvenInd(b)
odd = b([1,3,5,7,9])
even = b([2,4,6,8,10])
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.