Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started