Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use mathlab Extra Credit Function Name: puzzleBox Inputs: 1. (char) A jumbled character array 2. (double) The row shift vector 3, (double) The column

image text in transcribed

please use mathlab

Extra Credit Function Name: puzzleBox Inputs: 1. (char) A jumbled character array 2. (double) The row shift vector 3, (double) The column shift vector Outputs: 1. (char) The solved character array Banned Functions circshift() Background to get your special pal a box of chocolates for Valentine's day but forgot ut of chocolates, you decide to create a special until the last moment! Since the stores are sold o puzzle box to give as a present. And you can use MATLAB to help you do it! Function Description Write a function called puzzleBox that will take in a jumbled character array and two vectors (representing a row shift and a column shift) and produce a satisfying ASClI image. The last elements in the row and column shift vectors represent the number of shifts to make, while all other numbers in the vector represent which row/columns to shift For example, if the row shift vector was [3, 5, 1 12, 7], this would indicate that you should shift every element in row 3, 5 and 12 to the right by 7 columns (shifts should wrap around to column 1 if they go past the right edge of the array). Positive row shifts move elements to the right and positive column shifts move elements down. Negative shifts move in the opposite direction. columns Your code should be formatted such that the rows slide first, and then the Example Given the following inputs jumbledCharArr - rowShift = [1, 3, 21: abc def colshift [2, 5; You should first shift rows 1 and 3 by 2 elements to the right (wrapping elements around the end of each column). This procedure will produce the array afterRowShift ['bca def';... Hig' Then you should shift column 2 by 5 elements up (wrapping elements around the end of each row), Because the array is a 3x3, shifting by 5 in the upward direction is equivalent to shifting by 1 in the downward direction ("cough mod() 'cough"). Therefore, the final character array produced by these inputs is finalCharArr dcf heg'] Notes: The shift value can be any integer The index elements will always consist of valid row/column indices . Hints: You will find the mod() function very useful. Character arrays are just normal arrays in disguise

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_2

Step: 3

blur-text-image_3

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions