Homework 9 - File IO Notice This homework will require you to create functions that output text files. Text files cannot be checked against the solution output using ​isequal()​, but there is another...

Problem 3 and 4 only , 'rapLyricsrebooted' and 'avatars'


Homework 9 - File IO Notice This homework will require you to create functions that output text files. Text files cannot be checked against the solution output using ​isequal()​, but there is another function you can use to compare text files called ​visdiff()​. Suppose your output file is called 'outputFile.txt' and the solution function produces the file ​'outputFile_soln.txt'​. You will have to run both your function ​and the solution function with the same inputs to generate these files. Then use the ​visdiff() function to compare your output with the solution function's output. From the Command Window, type and run the following commands: >> functionName(in); >> functionName_soln(in); >> visdiff('outputFile.txt','outputFile_soln.txt'); At this point, a new window will pop up. This is the MATLAB File Comparison Tool. It will not only tell you if the selected files match, but it will also tell you exactly what and where all of the differences are. Use this tool to your advantage. Please note that sometimes the comparison will say, "No differences to display. The files are not identical, but the only differences are in end-of-line characters." Do not be alarmed if you see this; you will still receive full credit. Please keep in mind that your files must be named exactly as specified in the problem descriptions. The solutions will output files with '​_soln​' appended before the extension. Your output filename should be identical to the solution output filename, excluding ​'_soln'​. Misspelled filenames will result in a score of 0. You will still need to use ​isequal() to compare non-text-file function outputs. Also note: you can start the File Comparison Tool by clicking on "Compare" in the Editor ribbon if that is easier for you. MATLAB has lots of additional functions for reading/manipulating low-level text files, but because we want you to learn the fundamentals of low-level file I/O, ​we have banned fileread() and ​textscan() for all problems on this homework. The use of either of those functions on any problem will result in a 0 for that problem. Finally, please remember to ​close all files that you open​. The use of ​fclose('all'), fclose all, ​or ​close all ​is not permitted, so make sure to close each file individually. If files remain open after your code finishes running a test case during grading, ​you may be penalized​, even if your outputs are correct. Regrades will not be accepted for otherwise correct code that fails to close all files. Homework 9 - File IO This homework will also require you to create functions that output spreadsheet files. These cannot be directly compared using ​isequal​. However, we can compare them with a few lines of code! >> functionName(in…); >> functionName_soln(in…); >> check = isequal(readcell('file.xlsx'), readcell('file_soln.xlsx')); The inputs for each problem are of the following format, replacing X with either 1, 2, or 3 for the first, second, and third test case respectively. ● choraleLyrics(fileNameX) ● betterBetterBetterDataAnalysis(filenameX, inX) ● rapLyricsRebooted(filenameX, repWordX, wordsCaX) ● avatars(namePartX, outNameX) ● evilIsAfoot(fileX, sequenceX) Happy Coding! ~Homework Team Homework 9 - File IO Function Name: ​choraleLyrics Inputs: 1. (char)​ Name of the text file Outputs: 1. (double)​ Number of words in the text file Banned Functions: split(), strsplit() Background: As a proud member of the ​Georgia Tech Chorale​, you are excited for an upcoming performance! You wonder how many words are in the piece of music you're singing, so you ask MATLAB to help you out. Function Description: Write a function in MATLAB that takes in the name of a file, and counts the number of words in the file. On each line of the file, the words will be separated by spaces. Output this number of words. Example: file1.txt = Let the river run Let all the dreamers wake the nation Come the New Jerusalem count1 = choraleLyrics('file1.txt') count1 => 15 Notes: ● There may be any number of spaces in between words. ● There will be no punctuation. Hints: ● Be careful about lines with no words on them! https://music.gatech.edu/ensembles Homework 9 - File IO Function Name: ​betterBetterBetterDataAnalysis Inputs: 1. (​char​) The filename of the excel file containing garden data, including the ‘xlsx’ extension. 2. (char) ​The name of the header of the column to sort by File Outputs: 1. The updated Excel file, with the filename given from input 1, with ​'_updated.xlsx' appended Background: Still quarantined . . . . and still gardening . . . and best of all still learning MATLAB! Function Description: You’re given the filename of the Excel file containing data about your garden. The first row is guaranteed to be the headers of the columns. The remaining rows are the data of the cell array, with each row being a different plant. There will also be a ​'Height' ​column and 'Flowers' ​column, which may appear in any place in the Excel file. There may be additional columns as well. Update the Excel file in the following ways: 1. Create a ​'Scores' ​column and append it to the right of the array. The score for a plant is as follows: 3 * + 4 * 2. Delete any row whose ​'Scores' ​ value is less than the average ​'Scores' ​ value. 3. Sort the rows by the value in the column whose header is given by the second input. a. If the values in the column are type char, sort alphabetically in descending order b. If the values in the column are type double, sort in ascending order Example: 'Analysis.xlsx' -> fn = 'Analysis.xlsx' betterBetterBetterDataAnalysis(fn, 'Color') Homework 9 - File IO 'Analysis_updated.xlsx' -> Homework 9 - File IO Function Name: ​rapLyricsRebooted Inputs: 1. (​char​) The name of a text file containing lyrics 2. (​char​) Word to be replaced 3. (​cell​) A 1xN cell array containing replacement words File Outputs: 1. The updated text file Background: Happy with your work the last time you analyzed rap lyrics, this time you decide to take it a step further. Instead of just counting how many times a certain word has been said in rap lyrics, your new goal is to change the repetitive rap lyrics to make them more interesting! Function Description: Given a text file containing some rap lyrics, replace any occurrence of the word provided in the second input with words from the cell array provided in the third input. Replace the first
Jul 17, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here