shift.txt file nos: -3,9,-17 caeser txt 1 nos: 80,68,87,79,68,69,76,86,73,88,81
ID: 3863111 • Letter: S
Question
shift.txt file nos: -3,9,-17
caeser txt 1 nos: 80,68,87,79,68,69,76,86,73,88,81
caeser txt 2 nos: 76,74,86,75,89,86,87,70,73,84,86,67,76,66,86
caeser txt 3 no: 75,70,83,70,67,80,88,70,78,89,86,73,86,69,70,70,69,86,89,82,74,88,70,69,86,83,86,87,70,73,86
Homework goals: Creating and manipulating strings foe labels on graphs, filenames. 3D surface plotting, Reading and writing files. The Caesar Cipher is a simple encryption technique in which all letters are replaced by another letter a fixed number of positions down the alphabet For example, a right shift of 3 on the English alphabet would result in the following: In this example, the letter M is replaced by the letter P, which is three positions to the right of M. Using tins system with a right shift of 3, the string 'MATLABISFUN' would be replaced by 'PDWODELVIXQ'. If 'A' is encoded as 0, we can use the following equation to shift a single letter N = (x + s) % 26 where x is the numerical encoding of the letter, s is the Caesar Cipher shift size, and N is the numerical encoding of the new encrypted letter, (% indicates modulus division... recall the mod() function). The same equation can he used to shift every element in a sector. (Note that ASCII encodes A as 65 by default, so you need to shin your starting strings down by 65 so that A = 0 before you can use this equation.) Write a MATLAB script to do the following: Use to read in the shifts.txt file. Use to read in all of the cacsars.txt files from Canvas inside of a loop. For each cacsar#.txt file, perform a Caesar Cipher shift according to the corresponding value in shifts.txt. (E.g., shift the data in cacsarl.txt by the number of letters given by the first value in shifts.txt.) Print each decoded string (these should be letters, not numbers). Convert each decoded string back to numbers, and then use to write each decoded string to a different text file. To build the filename, combine the first 6 characters of the decoded string, the number of the file, and the string '_decoded' to build each filename. For example, the first file (generated from the data in caesarl.txt) should end up as MATLABI_decoded.txt. Include these files when you turn in your scripts. Self Cheek (they should all be recognizable English phrases): String 1: MATLAB------ String 2: U--T--F -----L--E String 3: T ------YG---------OO-----G---------EExplanation / Answer
We can start this process using a text editor, create a space-delimited ASCII file with column headers called myfile01.txt.
Import the file, specifying the space delimiter and the single column header.
filename = 'myfile01.txt';
View columns 3 and 5.
Import a Text File and Return Detected Delimiter
Using a text editor, create a comma-delimited ASCII file called myfile02.txt.
Import the file, and display the output data and detected delimiter character.
Import Data from Clipboard
Copy the following lines to the clipboard. Select the text, right-click, and then select Copy.
Import the clipboard data into MATLAB® by typing the following.
Input Arguments
collapse all
filename — Name and extension of file to import
character vector | string
Name and extension of the file to import, specified as a character vector or a string. If importdata recognizes the file extension, it calls the MATLAB helper function designed to import the associated file format (such as load for MAT-files or xlsread for spreadsheets). Otherwise, importdata interprets the file as a delimited ASCII file.
For ASCII files and spreadsheets, importdata expects to find numeric data in a rectangular form (that is, like a matrix). Text headers can appear above or to the left of the numeric data, as follows:
Column headers or file description text at the top of the file, above the numeric data.
Row headers to the left of the numeric data.
Example: 'myFile.jpg' or "myFile.jpg"
Data Types: char | string
delimiterIn — Column separator character
character vector | string
Column separator character, specified as a character vector or a string. The default character is interpreted from the file. Use ' ' for tab.
Example: ',' or ","
Example: ' ' or " "
Data Types: char | string
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.