Matlab programmingSolution Start with a function that can se

Matlab programming

Solution

Start with a function that can search the rows of a matrix for a string:

For example, this gives is the (row,column) location of the horizontal string sh in the matrix A:

That\'s great for horizontal strings, but what we want is the ability to search in all orientations and directions. We a new function, call it wordsearch, that will output the following:

To get this, we can build on strsearch to search for horizontal and vertical occurrences by transposing the matrix. Backwards occurrences can be found by flipping the input string. To search diagonals, we can use arrayfun and diag to extract the diagonals and search in a similar manner.

The general search function:

Wrap that with loops to search in all orientations/directions to get the wordsearch function:

Matlab programmingSolution Start with a function that can search the rows of a matrix for a string: For example, this gives is the (row,column) location of the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site