Question: Use matlab to finish it Fitting polynomials. (a) Write a script to create a vector x with 100 equally distributed values in the range from

Use matlab to finish it

Fitting polynomials. (a) Write a script to create a vector x with 100 equally distributed values in the range from -5 to 5 . Then calculate y=sin(2x)e^(-sqrt2x) with a perturbation (i.e., a random number in the range -0.5 to 0.5 , by using rand) at each entry of the vector y. Now you have two vectors x and y with 100 entries. (b) Then fit first, second, third, fourth, and fifth order polynomials to these points defined by the vectors x and y. (c) Plot the data (points determined by x and y ) as blue scatter dots (or others, e.g. stars) and a red solid line with a thickness 3 points on a figure, further plot all five polynomial.Label the figure appropriately, including xlabel and ylabel. A suitable title should be given.

Hint: To get good fits, you may have to use the centering and scaling version of polyfit(the one that returns

threearguments, seehelp) and its counter part in polyval(the one that accepts the centering and scaling parameters).

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 Databases Questions!