Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROGRAMMING IN MATLAB WORD SEARCH PROGRAM IGOLCQNRKSXT LXHSRNKANSAS MPAYAWCSAXET

ID: 3788261 • Letter: P

Question

PROGRAMMING IN MATLAB

WORD SEARCH PROGRAM

IGOLCQNRKSXT

LXHSRNKANSAS

MPAYAWCSAXET

MNDUFLNNIBMS

APISOXAOJKJA

IVSCDCWSDAND

NHLKRACJKFGA

EAOREGONCABV

KWTLBOHOLELE

PAJBBAHAGDEN

VILFDIYKTGAX

XIKVOWPCLUYW

write an m-file in Matlab which can perform a word search, such as what you might find in a puzzle book. Words will be located somewhere in a two-dimensional array of letters. The instructor will provide an array for the groups to use to help test their program. This array contains all of the states in the United States that are six characters in length or less. Each group should store the word search file on their own disk or P-drive.

Each group will provide the following for this lab:

A working program: The program code should be commented in sufficient detail to allow the reader to understand the coding approach.

A write-up which includes:

a high-level flowchart of the operation of the program

an attachment to your Word document of the m-file code

include a cover sheet, with name(s), class, date and lab number

include this signed-off page scanned as an attachment if your program has been successfully demonstrated

the write-up should convey how the program was developed, what issues were encountered, whether the program was successful (and if not, why not), etc.

Lab Details

1. The program should be able to read in the following data files:

The word search file – this file contains the word search array

The file of words to be searched – the executed program should be able to scan for each word (state) in this file and locate that word in the word search.

Note that words in the word search may go in any of eight directions.

2. The result of executing the word search program should clearly indicate where each word begins in the word search array (row and column), and which direction it travels (e.g., up and to the right, straight down, etc.). The word search should be flexible such that if the words are placed in a different word search of the same grid size (12x12), the new word locations will still be found.

Explanation / Answer

%// Example word grid C = [ 'a' 'h' 'c' 'k' 'r' 'x' 'r' 'j' 'i' 'p' 'b' 'v' 't' 'l' 'q' 'a' 'y' 'q' 's' 'o']; %// Your search term target = 'arts'; %// Optionally, do some obvious checks here. %// - length of the search string may exceeds the grid's dimensions %// - there are no matches for the first letter %// - and similar %// Form single cellstring containing all search directions allDirections = [ %{ // horizontal, horizontal-reversed %} cellstr([C ; C(:,end:-1:1)]) %{ // vertical, vertical-reversed %} cellstr([C'; C(:,end:-1:1)']) %{ // Diagonal, top-left to bottom-right, and reversed %} arrayfun(@(ii){diag(C,ii)'}, -size(C,1)+2:size(C,2)-2)'; arrayfun(@(ii){diag(C(end:-1:1,end:-1:1),ii)'}, -size(C,1)+2:size(C,2)-2)'; %{ // Diagonal, top-right to bottom-left, and reversed %} arrayfun(@(ii){diag(C(:,end:-1:1),ii)'}, -size(C,1)+2:size(C,2)-2)'; arrayfun(@(ii){diag(C(end:-1:1,:),ii)'}, -size(C,1)+2:size(C,2)-2)'; ]; %// And now just find the string strfind(allDirections , target)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote