1) Write a Matlab script that reads the file populationData.mat and plots its data using blue asterisks. 2) Let us consider a polynomial approximation under the least squares criterion. 2.a) Propose a value for the degree of the polynomial to be used. 2.b) The polynomial that approximates some data can be computed using Matlab func- tion polyfit. Once the polynomial is computed, it can be evaluated at any point using the function polyval. Look at the Matlab help and learn how to use function polyfit. What the input parameters represent? What variables does it return? What do they mean? 2.c) Now, look at the Matlab help and learn how to use function polyval. What are the input parameters? What variables does it return? What do they mean?. 2.d) Compute the polynomials of degree m = 1, m = 3 and m = 5 that approximate the data. Plot the data along with the polynomials you have obtained. 2.e) Compute the error of each polynomial. Which one is the best approximation? 2.f) In 2012, population in Spain was 47.220 million people. Which one of the three polynomials provides a more accurate forecast? 2.g) You got a warning message indicating that the normal equations are ill-conditioned. Look at the matlab help and propose a way to increase the accuracy of the ap- proximation. Repeat questions 2.d) - 2.g) using the procedure you have proposed. Have you obtained the same results than in the previous point? Justify whether this behaviour is reasonable. 3) Let us consider the parameter identification of a non-linear model that can be linearized, leading to a linear regression problem. 3.a) Population models are widely used in social sciences. For instance, the exponential model describes the evolution in time of the population as. p(t) = a exp(Bt). Although this is a non-linear model, parameters a and 3 can be computed solving a linear least-squares problem (linear regression) y = A + Bx with y = ln(p), x = t, and A = ln(a), B = B. Compute the linear regression that approximates these transformed data and deter- mine the value of coefficients a and 3.
3.b) Plot the data along with the obtained approximation. 3.c) Compute the error of this approximation. Is it better or worse than the polynomial ones? 4) Finally, we want to compute an interpolative approximation that passes through all the data points. 4.a) Which is the degree of the polynomial that meets this requirement? 4.b) Suggest a way to compute this polynomial using polyfit matlab function. 4.c) Compute the polynomial that passes through all the data points. Detail the forecast for 2012 and its error.
T px t 14x1 double 1 18.6166 19.9907 21.3886 23.6771 26.0143 28.1179 30.5829 33.9560 37.7426 39.4339 40.4998 44.7090 46.0635 47.0210 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 tx 14x1 double 1 1900 1910 1920 1930 1940 1950 1960 1970 1981 1991 2001 2006 2008 2010
1) Write a Matlab script that reads the file populationData.mat and plots its data using blue asterisks. 2) Let us consi
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
1) Write a Matlab script that reads the file populationData.mat and plots its data using blue asterisks. 2) Let us consi
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!