Question: Matlab help needed in this problem you will write a function to decrypt a matrix representing a character and use it to decode a message.

Matlab help needed

in this problem you will write a function to decrypt a matrix representing a character and use it to decode a message. a) Create a Function to Decrypt a Single Letter Write an external, user-defined function that takes two inputs: An 11x11 matrix containing an encrypted, pixelated representation of a letter, as in Application 1 An 11x11 key matrix And returns as an output: The letter represented by the matrix as a character (e.g. A, B, etc.) If no letter matches, return a blank space ( ) An example of how the function should work is shown below: >> decrypt_letter (letter_mat, key_mat) ans = 'A'

One approach to this problem is as follows: Load the known letter matrices from Application 1 Apply the xor operation to decrypt the unknown letter matrix. Using either a loop or a big ifelseif..else structure (there will be 27 branches!), apply your image_compare() function from Exercise 6 to compare the unknown letter matrix to each of the 26 known letter matrices, and return the corresponding letter when you get a match. (Copy your Exercise 6 code into a .m file and save it in the same folder as your script and this function.) If there is no match, return a blank.

to use a loop, it may be helpful to put the 26 known letter matrices into a single larger matrix. One way to do that is to make a 3D matrix like this: >> all_letters = cat(3, A, B, C, );

The indexing to access a single letter would then be all_letters(:, :, k), where k = 1 for A, k = 2 for B, etc. This method may be a little more difficult than the if/elseif/else method, but it makes the code more compact.

b) Apply the decryption function to a message. You are provided with a function called generate_message() that will return a randomly selected, encrypted message matrix and an 11x11 key matrix. NOTE: This is a little different than in Application 1 here the key is not the same size as the entire message, but only the same size as one letter. Call this function to generate a secret message and key. Using a loop, pass the message, one letter (11 columns) at a time, along with the key matrix to your decryption function. Print the decoded message to the command window.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!