Project #4 Curve fitting and interpolation == Exploration WINTER 2014 pp4.txt Distributed… 4/8/2014 Due: 4/17/2014 Experiment with MatLab's polyfit function. (1) Create a 1 X 100 array containing only ones (use ones). No Noise. Plot the data values as points (not a line). Find a line (two coefficients) using polyfit() that does a least squares fit on the data. Plot the fitted line together with the data points. (2) Take the same 1 X 100 array containing only ones. Add 10% noise; noise value will be random and range between [-0.05 and +0.05] . Each noisy value is the sum of the original value plus the noise value * original value. % x = ones(100); % noise values --> for el = 1:100 n(el) = random value in [-0.05, +0.05] % noisy data --> xn = x + n Repeat the plot of data points, and polyfit() line of two dimensions Plot data and fitted curve on one plot. (3) Repeat (2) where the noise is 50% noise. (4) On the noisy data of (3), do a polyfit() where the number of dimensions is 5. Plot the data and the fitted curve on one plot. Is there an advantage to having excess dimensions? (5) Interpolate the fitted curves of (2) and (3) at t = 25.5, 50.5, 75.5. Which fitted curve (from (3) and from (4) ) gives better interpolated values for the noisy data? Which fitted curve gives better interpolated values for the data prenoise. ------- Now presume quadratic data ----------- (6) Repeat (1) , but for the 1X100 array containing values at t = 1:100 of p(t) = 1 - 4*t + 2t^2 (fit a straight line) (7) Repeat (2) on the new data points with added 20% noise. ( [-0.1, +0.1] ) (Fit a straight line) (8) Repeat (3) on the new data points with 20% noise. Now fit a 2nd order polynomial. (9) On the new data, with 20% noise, fit a *tenth* order polynomial) (10) Interpolate the fitted curves from (7), (8), (9) at points t=[25.5, 50.5, 75.5]. Which fitted cure give better interpolated values for noisy data and for noise-free data? Turn in: Demo!! All code, hardcopy. All plots, hardcopy, appropriately labelled to avoid any ambiguity. Fill in the following table. (Table is coming) Grade based on: Correctly functioning code Plots and code copy Table Good variable, function names Good code structure (using user defined functions, no excess computation, ...)