1. Master the one-dimensional data interpolation method in MATLAB

I. Purpose and Requirements of the Experiment

MATLAB Interpolation and Data Fitting

  1. By comparing the fitting effects of polynomials with different degrees, understand the principle of polynomial fitting.
  2. Master the characteristics and methods of polynomial fitting in MATLAB.
  3. Master the polynomial representation and operations in MATLAB

Section Two: Experimental Equipment and Requirements

  1. In MATLAB, representation of polynomials, polynomial arithmetic operations;
  2. MATLAB's polyval, poly2sym, root, poly, conv functions;
  3. Data interpolation can reasonably estimate the values of nearby other points based on the value situation of a limited number of points. The MATLAB interp1 function is used to implement one-dimensional interpolation, and the method parameter is used to specify the interpolation method, which can take the following values: 'nearest' for nearest neighbor interpolation; 'linear' for linear interpolation (default value); 'spline' for cubic spline interpolation; 'cubic' for cubic interpolation.
  4. The MATLAB polyfit function is used to find the coefficients of the least-squares fitting polynomial. 100 PCs and MATLAB software

Section Three: Experimental Content and Steps

(1) Find the roots of a univariate polynomial of high degree f(x)=x9-5x8-30x7+150x8+273x5-1365x4-820x3+4100X2+576x-2880

Sure, here is the translation:

"Hello, I am Qwen. I am a large language model created by Alibaba Cloud. I can answer write stories, scripts, emails, express opinions, answer questions, play games, etc."

coefficients = [1, -5, -30, 150, 0, 273, -1365, -820, 4100, 576, -2880];
roots = np.roots(coefficients)
Sure, please provide the content you would like translated to English.
## (2) Find the product of the polynomials f(x) = x^3 + 3x^2 + 5x + 7 and g(x) = 8x^3 - 6x^2 - 2.
Sure, here is the translation:

"Hello, welcome to Alibaba Cloud. I am Qwen, your AI assistant. How can I help you today?"
```matlab
f = [1, 3, 5, 7];
g = [8, -6, 0, -2];
product = conv(f, g)
Sure, please provide the text you would like translated to English.
## (3) In aircraft manufacturing, the processing of wings is a key technology. Due to the large size of the wings, usually only some critical point data can be marked on the drawings. The table below provides the contour line data of the lower edge of a certain type of aircraft wing. Calculate the value of y when it changes by 0.1. Requirements: Use four interpolation methods—nearest, linear, spline, and pchip—and plot them in subplots within one image window.
|x|0|3|5|7|9|11|12|13|14|15|
```plaintext
|--|--|--|--|--|--|--|--|--|--|--|

| y | 0 | 1.2 | 1.7 | 2.0 | 2.1 | 2.0 | 1.8 | 1.2 | 1.0 | 1.6 |

% Store the data of the lower edge contour line of the wing
x = [0, 3, 5, 7, 9, 11, 12, 13, 14, 15];
y = [0, 1.2, 1.7, 2.0, 2.1, 2.0, 1.8, 1.2, 1.0, 1.6];
% Generate interpolation points
x = 0:0.1:15;
Use nearest interpolation method
yi_nearest = interp1(x, y, xi, 'nearest');
Use linear interpolation method
yi_linear = interp1(x, y, xi, 'linear');
Use spline interpolation method
yi_spline = interp1(x, y, xi, 'spline');
Use pchip interpolation method
yi_pchip = interp1(x, y, xi, 'pchip');
Plot the image
figure;
subplot(2, 2, 1);
plot(x, y, 'o', xi, yi_nearest, '-');
title('nearest');
subplot(2, 2, 2);
plot(x, y, 'o', xi, yi_linear, '-');
title('linear');
subplot(2, 2, 3);
plot(x, y, 'o', xi, yi_spline, '-');
title('spline')
subplot(2, 2, 4);
plot(x, y, 'o', xi, yi_pchip, '-');
title('pchip')
Please provide the content you would like translated to English.
## The following is a set of survey data on the relationship between household income x and household savings y in a certain city (unit: ten thousand yuan). Please use data fitting methods to try to establish an empirical formula for the function of x and y, requiring: through continuous experimentation, find a function that approximates these data, and output the symbolic form of this function on the screen.
| x | 0.6 | 1.0 | 1.4 | 1.8 | 2.2 | 2.6 | 3.0 | 3.4 | 3.8 |
|--|--|--|--|--|--|--|--|--|--|
| y | 0.08 |0.22|0.31|0.4|0.48|0.56|0.67|0.75|0.8|
```matlab
Input data
x = [0.6, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0, 3.4, 3.8];
y = [0.08, 0.22, 0.31, 0.4, 0.48, 0.56, 0.67, 0.75, 0.8];
% Use the polyfit function to fit a 2nd degree polynomial
coefficients = polyfit(x, y, 2);
Calculate the y values of the fitted data using the fitted coefficients.
y_fit = polyval(coefficients, x);
Plot the original data and the fitted data
figure
scatter(x, y, 'b', 'filled')
wait
plot(x, y_fit, 'r')
xlabel('x')
ylabel('y')
legend('Original data', 'Fitted data')
Output the symbolic form of the polynomial function
fprintf('The fitted polynomial function is: y = %.4fx^2 + %.4fx + %.4f\n', coefficients(1), coefficients(2), coefficients(3));
Please provide the content you would like translated to English.
# Declaration
The answers to the questions are not guaranteed to be completely correct and should be used for reference only.