Ask Question
24 January, 17:17

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.

+2
Answers (1)
  1. 24 January, 17:28
    0
    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';
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a function called interleave to interleave two row arrays of equal length. Ex: For row arrays arrayOne and arrayTwo, the output row ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers