Assignment InstructionsThe purpose of this assignment is to show that you can...below you will find the pictures for the full question.Read data from a file.Write data to a filePlot data.




Assignment Instructions




The purpose of this assignment is to show that you can...




below you will find the pictures for the full question.










  • Read data from a file.








  • Write data to a file








  • Plot data.








= DO THIS ONLY USING methods and practices demonstrated in class. These include... = Sequences or Vectors. = The functions "fopen", "fprintf", "fclose”, etc... = "if", "for", "while", "break", "continue" statements = Arithmetic, relational and logical operations. = DO NOT USE other built-in matlab functions. = Such as... writecell";'writematrix",'writetable""cvswrite", "save", "fwrite", or other similar functions. = If unsure, ask the instructor. = HINT: See ">> help fprintf" for formatting your print output. = HINT: It is easier to write only some characters at a time to a file; instead of trying to write an entire line all at once. = HINT: "\n' is used to represent a carriage return. + Create a function "readDataFile" which takes an argument: a character array "filename”..in that order. This function wijll read the text file called "filename" in the same format identified above for result slixt ¥ and results2.txt 1 . From that data it will create a cell array "data" variable which will have the following structure... { {char array} {uintie} {double} {double} {double} {double} {double} {double} {double} {double}; {char array} {uint16} {double} {double} {double} {double} {double} {double} {double} {double}; {ever array} {uinti6} {double} {double} {double} {double} {double} {double} {double} {double} } o Each cell array row represents another row read from the file. The cell array columns are "ObjectName, Velocity, Distance1, Distance2,....Distance8" in that order. "readDataFile" will return this cell array, "data". = For example... >> example data = readDataFile('example data.txt') example data = 2x10 cell array Columns 1 through 5 {'Objectl'} {[1001} {1.10001} {[1.2000]} {[1.30001} {'Object2'} {[2001} {2.10001} {[2.2000]} {[2.3000]1} Columns 6 through 10 {[1.40001} {[1.50007}% [1.600011 {[1.70001} {1.80001} {[2.4000]} {2.50001} {[2.60001} {[2.70007} {[2.80001} >> >> cellplot (example data); $%save to example cellplot.png And the distance range it traveled “r" is... r=wvx"'t You decided to test these equations by running experiments with a "tennis ball”, a "base ball", and a "lead ball" over several initial velocities and angles. You collected data and saved iti in two files resultsl.txt ¥ and results2.txt | . In these files, each row is formatted as.. (objectName Velocity Distancel Distance? Distance3 Distance4 DistanceS Distance6 Distance? Distances where"ObjectName" is the name of the object throw, "Velocity" is the initial velocity of the object, "Distance" is the distance that object travel thrown at that velocity at an angle of "10", “Distance2" for at an angle of "20", .. .,» and "Distance8" for at an angle of 80. ObjectName is a single word. Velocity is a positive integer. Distancel-8 are floatin is separated by a single space and each row is terminated by the '\n' character. 8. pointumbers. Each value “For this homework assignment you will... and results2.txt J » Create a function "writeDataFile" which takes two arguments: a character array "filename", and a cell array "data"...in that order. This function will create and write to a text file named “filename” in the same format identified above for results1.txt Include data from the cell array "data" which will have the following structure. . There is no return value. The output of this function is the file created with information inside. { {char array} {uintie} {double} {double} {double} {double} {double} {double} {double} Ay = oer array} {uinui6) {double} {double} {double} {double} {double} {double} {double} {double}; ichar array} {uinti6} {double} {double} {double} {dpuniey {double} {double} Tonle {depts 3. o Each cell array row represents another row to write to the file. The cell array columns are "ObjectName, Velocity, Distance1l, Distance2,....Distance8" in that order. "writeDataFile" will return nothing. = For example... >> example data = { 'Objectl', uintie6(100), 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8; "object?! inint16 (200), 2.1, 2.2,2.3, 2.4, 2.5,2.6 2.72.8} >> writeDataFile (/example data.txt' example data) ; See "example data.txt' created file here. + ~~ we degree angle from the ground, “a”, and gravity “g".. ih i a | Lf YUSING methods and practices demonstrated in class. These include es or Vectors. nctions "textread", etc... " » "for" "while", "break", "continue" statements etic, relational and logical operations. )T USE other built-in matlab functions. ich as... “readcell’,'readmatrix’,'readtable";'textscan""strread""save" "csvread", or other similar functions. If unsure, ask the instructor. INT: See ">> help textread" to format the read into the correct variable data types. T: All numbers are returned as "double" so you may need to convert (or cast) them into another data type. NT: "unit16(10)" will create a floating point double "10" into an unsigned integer "10" i. function "plotData" which takes two arguments: a cell array "data", and a character array "name"...in that order. This function will plot (on a single orl al data name" is to be added as a subtitle for each plot. "plotData" will return nothing. Format plots with axis labels, point markers, grid lines, titles, subtitles, and gend. format "ObjectName-ObjectVelocity". See the examples below for everything needed. = >> example data = readDataFile(' example data.txt'); _ >> plotData (example data, 'Example') ;
Apr 16, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here