Question

2. The population of the world for selected years from 1750 to 2009 is given in the following table: Year Population (million

I want -C parts- using matlab

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the required MATLAB script for part (C) :

%==================================================================================

clear all;clc;format short

x = [1750,1800,1850,1900,1950,1990,2000,2009];
y = [791,980,1260,1650,2520,5270,6060,6800];

% Linear fit
p = polyfit(x,y,1); % Order 1 polynomial is essentially a line
y_lin_fit = polyval(p,x);
lin_1975 = polyval(p,1975);

% spline fit
y_spline_fit = interp1(x,y,x,'spline');
spline_1975 = interp1(x,y,1975,'spline');

fprintf('Population in 1975:\n1) by Linear fit: %f million, 2) by Spline fit: %f million\n',lin_1975,spline_1975);

figure
scatter(x,y)
hold on
plot(x,y_lin_fit,'-r')
hold on
plot(x,y_spline_fit,'--g')
legend('Original Data','Linear fit','Spline fit')
grid on
xlabel('Year')
ylabel('Population (million)')

%================================================================================

Output:

Population in 1975:
1) by Linear fit: 4717.218881 million, 2) by Spline fit: 4098.602853 million

7000 O Original Data Linear fit -Spline fit 6000 5000 4000 Population (million) 3000 2000 1000 0 -1000 1750 1800 1850 1950 20

In case of any clarification required, please comment!

******** PLEASE THUMBS UP!!!!!!! ********

Add a comment
Know the answer?
Add Answer to:
I want -C parts- using matlab 2. The population of the world for selected years from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with parts A B D E and F. Please show hand work for...

    I need help with parts A B D E and F. Please show hand work for solving A and B while D and E should be matlab codes. How do i pick the right graph for part F? 5 2 4 6 Linear spline: s fi+ (x-x) 2) Given the points 40 78 125 256 348 425 X1-x a) Write the correct linear spline equation to interpolate for x 4.72, simplifying where appropriate to get to the slope-intercept form. (4...

  • A wind tunnel test conducted on an airfoil section yielded the following data between the lift...

    A wind tunnel test conducted on an airfoil section yielded the following data between the lift coefficient (CL) and the angle of attack (?): 12 1.40 16 1.71 20 1.38 de CL 0.11 0.55 0.95 You are required to develop a suitable polynomial relationship between ? and CL and fit a curve to the data points by the least-squares method using (a) hand calculations and (b) Matlab programming Hint: A quadratic equation (parabola) y(x)-aa,x +a x' can be used in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT