Question: Adjacent Repeat of Numbers in an Array Write a function called DoubleLetterCheck ( ) that uses loops to determine if any two adjacent characters in
Adjacent Repeat of Numbers in an Array
Write a function called DoubleLetterCheck that uses loops to determine if any two adjacent characters in a string array are the same.
The input argument is a character array called inString.
The output argument is an integer scalar called DoubleLetters. This value is set to an integer value of if two character next to one
another are the same in the array. Otherwise, this value is set to
Ex: Given
inString 'chocolate chip cookie';
DoubleLetters DoubleLetterCheckinString
The output is:
DoubleLetters
because of the two o characters in 'cookie'.
Ex: Given
inString 'chocolate fudge icecream';
DoubleLetters DoubleLetterCheckinString
The output is:
DoubleLetters
No adjacent characters are the same.
Remember that MATLAB functions such as numel can be used to get the number of elements in a D array. One possible strategy is to
iterate from position to the number of elements, and during each iteration, check each preceding element to see if a match exists.
Function
Code to call your function
inString 'chocolate chip cookie';
DoubleLetters DoubleLetterCheckinString
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
