Question
Using MATLAB ML2.txt file: 164 1976 684 27824 9180 4580 20 16604 66260 43956 39547 1577 109 7861 511 3811 24721 14519 60221 11 9402
Using MATLAB
ML2.txt file:
164 1976 684 27824 9180 4580 20 16604 66260 43956 39547 1577 109 7861 511 3811 24721 14519 60221 11 9402 18 6150 240 582 3828 2238 13806 1206 78 8388 29979 13441 516 1269 20484 4911 163 2644 36 111 21 1011 387 4191 2193 11907 7311 27183 18381 - 877.350 -8773.425 -264.007 -503.428 -122.088 -1428.774 - 3266.128 -4668.058 -2206.700 -6479.490 251.976 46.662 121.322 178.650 77.993 343.300 587.942 745.260 928.575 454.622 11133.000 22395.000 40617.000 68211.000 107949.000 162963.000 236745.000 333147.000 456381.000 611019.000 5198.684 361.312 205.399 933.118 3886.360 596.031 1399.278 2024.356 2841.341 6820.726 7.036 -1.275 26.444 121.569 211.300 62.453 340.152 517.634 1061.522 754.254
Importing, Sorting, Fitting, and Exporting Data Write a program that loads a 1010 array of numbers from the data file (ML2.txt) given on Canvas and sorts that data from smallest absolute value to largest absolute value for each row. Use the Load function we learned in class to input the data from the text file into Matlab (remember to put the file in the Matlab current folder). First, sort the values in each row using the Matlab 'sort' function. Remember to account for absolute value in your sorting but make sure the number that start negative are still negative afterward (the sorting is discussed more in the Appendix). Each row contains the y-values. The x-values are divided into two halves. The first 5 rows use x-values from 1 to 10 . If both the sorting is correct and the x-values are correct, the first set of data points would be: (1,20),(2,164),(3,684),(4,1976),(5,4580),(6,9180),(7,16604),(8,27824),(9,43956),(10,66260) The second 5 rows use x-values from 5 to 14 . Use the functions we learned in class to convert each row to a polynomial expression (hint: polyfit). Fit each row of the sorted data to a 4th order polynomial. Once you do this, look at the coefficients. First 5 polynomials: Take the numbers in front of each term and round them to the nearest integer. Do these numbers mean anything? Look at the coefficients in each row of the first 5 rows, do any of these numbers jump out at you? What if you looked that the coefficients as one digit each in a long number with a decimal between the first and second digit? Do they remind you of anything? Example: 3x4+x3+3.98x2+x+5.12 would be the number 3.1415 which is pi Once you figure out what the numbers represent, output these polynomials using an appropriate label (output described below). Here is a hint/riddle to help you: Naturallye, when you are exercising, alternate between Planck's and Boltzmaning to make your Avogadros Lighter. Second 5 polynomials: In the second 5 rows, keep the decimals on the coefficients of the terms in the polynomial! These polynomial expressions link to math functions shown in the table below using Taylor Series Expansions. Figure out which row corresponds to which expression(s). Some may be modified with a coefficient or be the combination of two expressions. Once you match them up, output the math functions with the expression from the row (output described below). Example: 21x2+0.083x4 would be 2cos(x) To output the data, make a new text file named ML2Output_LastName.txt and use fprintf to print to the data file. For the first half of the equations, make a label at the beginning of the row and then output the polynomial expression formatted as shown: Label: 3x41x3+4x21x+5 For the second half of equations, show the mathematical expression beside the polynomial expression as shown: 1/(1x)=x4+x3+x2+x+1Or71/(1x)=7x4+7x3+7x2+7x+7 Please use the variable replacement syntax in your fprintf (the \% holders for variables as shown in the slides). Matlab is not ideal for superscripts, so use the carrot notation shown
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started