Answered step by step
Verified Expert Solution
Link Copied!

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 1 if two character next to one
another are the same in the array. Otherwise, this value is set to 0.
Ex: Given
inString = 'chocolate chip cookie';
DoubleLetters = DoubleLetterCheck(inString)
The output is:
DoubleLetters =1
because of the two 'o' characters in 'cookie'.
Ex: Given
inString = 'chocolate fudge ice-cream';
DoubleLetters = DoubleLetterCheck(inString)
The output is:
DoubleLetters =0
No adjacent characters are the same.
Remember that MATLAB functions such as numel can be used to get the number of elements in a 1D array. One possible strategy is to
iterate from position 2 to the number of elements, and during each iteration, check each preceding element to see if a match exists.
Function o.
Code to call your function ?
1 inString = 'chocolate chip cookie';
DoubleLetters = DoubleLetterCheck(inString)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

What are some benefits of using debt financing?

Answered: 1 week ago

Question

Answered: 1 week ago

Answered: 1 week ago

Question

We will be opening our new facility sometime this spring.

Answered: 1 week ago