Q:

Write a function called interleave to interleave two row arrays of equal length. Ex: For row arrays arrayOne and arrayTwo, the output row array is arrayThree = [arrayOne(1), arrayTwo(1), arrayOne(2) ,arrayTwo(2), …]. The function should work for rows of any length. Hint: Create a new array by concatinating arrayOne and arrayTwo, then flattening the array to finally end up with the desired row array. No internal functions are needed. Ex: Flattening a=[1,2;3,4] gives [ 1; 3 ; 2; 4]. Restrictions: For and while loops should not be used.

Accepted Solution

A:
Answer:function [ repPos, pinCodeFix ] = pinCodeCheck( pinCode )       pinCodeFixTemp = pinCode;       repPosTemp = [];   for i = 1:length(pinCode)       if((i > 1)) & (pinCode(i) == pinCode(i - 1))           repPosTemp([i]) = i;       else           repPosTemp([i]) = 0;       end   end   for i = 1:length(pinCode)       if(repPosTemp(i) > 0)           pinCodeFixTemp(i) = 0;       end   end   repPosTemp = nonzeros(repPosTemp);   pinCodeFixTemp = nonzeros(pinCodeFixTemp);   repPos = repPosTemp';   pinCodeFix = pinCodeFixTemp';