Question
matlab

For this problem you will test a few interpolation approaches for the application of generating interpolated data. Well do t

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

Matlab Copde

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

close all,
clear all,
clc,

x=0:1:10;

Fx=[];
for n=1:length(x)
Fx(n) = 1/(1+(25*x(n)^2));
end
subplot(3,2,1); plot(x,Fx); title('Original Data Plot');

xi = 0:0.5:10;
Fxi=[];
for n=1:length(xi)
Fxi(n) = 1/(1+(25*xi(n)^2));
end
subplot(3,2,2); plot(x,Fx); title('Test Data used for Interpolation Testing');

%Linear Interpolation
Fi_L = interp1(x,Fx,xi,'linear');
subplot(3,2,3); plot(xi,Fxi,'r',xi,Fi_L,'b'); title('Test Data (Blue) and Interpolated Data (Red) using Linear Interpolation');

%Polynomial Interpolation
p = polyfit(x,Fx,(length(x)-1));
Fi_P = polyval(p,xi);
subplot(3,2,4); plot(xi,Fxi,'r',xi,Fi_P,'b'); title('Test Data (Blue) and Interpolated Data (Red) using Polynomial Interpolation');

%Polynomial Interpolation
Fi_S = spline(x,Fx,xi);

subplot(3,2,5); plot(xi,Fxi,'r',xi,Fi_S,'b'); title('Test Data (Blue) and Interpolated Data (Red) using Cubic Spline Interpolation');

ProjectPath = pwd;
FilePath = strcat(ProjectPath,'\InterpolationData.txt');
fpt = fopen(FilePath,'wt');
fprintf(fpt,'Interpolation Data Points\n');
for r=1:length(x)
fprintf(fpt,'%5d%10.4f\n',x(r),Fxi(r));
end
fprintf(fpt,'\n\nData Used for Interpolation Testing\n');
for r=1:length(xi)
fprintf(fpt,'%5d%10.4f%10.4f%10.4f%10.4f\n',xi(r),Fxi(r),Fi_L(r),Fi_P(r),Fi_S(r));
end

InterpolatedData=[];
disp([' xi Fxi Fi_L Fi_P Fi_S']);
InterpolatedData=[InterpolatedData xi' Fxi' Fi_L' Fi_P' Fi_S']

fclose(fpt);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Original Data Plot Test Data used for Interpolation Testing 0.5 0.5 2 3 45 6 78 910 2 3 4 5 678910 Test Data (Blue) and Inter

Matlab Output

Warning: Polynomial is badly conditioned. Add points with distinct X
values, reduce the degree of the polynomial, or try centering
and scaling as described in HELP POLYFIT.
> In polyfit at 80
In MatlabCodes at 25
xi Fxi Fi_L Fi_P Fi_S

InterpolatedData =

0 1.0000 1.0000 1.0000 1.0000
0.5000 0.1379 0.5192 0.2285 0.3309
1.0000 0.0385 0.0385 0.0385 0.0385
1.5000 0.0175 0.0242 0.0107 -0.0207
2.0000 0.0099 0.0099 0.0099 0.0099
2.5000 0.0064 0.0072 0.0076 0.0166
3.0000 0.0044 0.0044 0.0044 0.0044
3.5000 0.0033 0.0035 0.0028 0.0005
4.0000 0.0025 0.0025 0.0025 0.0025
4.5000 0.0020 0.0020 0.0022 0.0027
5.0000 0.0016 0.0016 0.0016 0.0016
5.5000 0.0013 0.0014 0.0011 0.0011
6.0000 0.0011 0.0011 0.0011 0.0011
6.5000 0.0009 0.0010 0.0012 0.0010
7.0000 0.0008 0.0008 0.0008 0.0008
7.5000 0.0007 0.0007 0.0003 0.0007
8.0000 0.0006 0.0006 0.0006 0.0006
8.5000 0.0006 0.0006 0.0019 0.0006
9.0000 0.0005 0.0005 0.0005 0.0005
9.5000 0.0004 0.0004 -0.0070 0.0004
10.0000 0.0004 0.0004 0.0004 0.0004

>>

Add a comment
Know the answer?
Add Answer to:
matlab matlab For this problem you will test a few interpolation approaches for the application of generating interpolated data. We'll do this by interpolating data that is sampled from a k...
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
  • Write a complete set of Matlab instructions that implements cubic spline interpolation on the following data...

    Write a complete set of Matlab instructions that implements cubic spline interpolation on the following data (assume clamped-end-condition). Your code should: a. Generate a single plot, over the range 0<= x <= 5, displaying: i. the individual data points ii. the generated spline function b. Predict the interpolated value at x = 0.5, x = 0.8 and x = 3.7 X у 0 1.7 1 0.3 2 1.8 3 0.4 4 2

  • 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...

  • I want -C parts- using matlab 2. The population of the world for selected years from...

    I want -C parts- using matlab 2. The population of the world for selected years from 1750 to 2009 is given in the following table: Year Population (millions) 1750 791 1800 980 1850 1,260 1900 1.650 1950 2,520 1990 5,270 2000 6,060 2009 6,800 (a) Determine the exponential function that best fits the data. Use the function to estimate the population in 1980. Make a plot of the points and the function. (b) Curve-fit the data with a third-order polynomial....

  • matlab The error function is a mathematical function that frequently arises in probability and statistics. It also c...

    matlab The error function is a mathematical function that frequently arises in probability and statistics. It also can show up in the solution to some partial differential equations, particularly those arising in heat and mass transfer applications. The error function is defined as 2 e-t dt picture attached This function is actually built-in to MATLAB as the command erf, and here we'll use that function to compute a "true value" with which we can compare results of two interpolation approaches....

  • 1. Runge's function is written as f(x) = 1 25r2 (a) Develop a plot of this function for the inter...

    1. Runge's function is written as f(x) = 1 25r2 (a) Develop a plot of this function for the interval from x =-1 to 1 using Matlab (no submission required). Develop the fourth-order Lagrange interpolating polynomial using equispaced function values corresponding to xi =-1,-0.5, 0, 0.5, and 1. (Note that you first need to determine the (a. ) pairs.) Use the polynomial to estimate f(0.9). (b) What is et? (c) Generate a cubic spline using the five data points from...

  • Consider the following data table: 0 2i = 0.2 0.4 f(xi) = 2 2.018 2.104 2.306...

    Consider the following data table: 0 2i = 0.2 0.4 f(xi) = 2 2.018 2.104 2.306 0.6 0.2 and 23=0.4 is The linear Lagrange interpolator L1,1 (2) used to linearly interpolate between data points 12 (Chop after 2 decimal places) None of the above. -2.50x+0.20 -5.00x+2.00 -5.00x+2.00 5.00x-1.00 Consider the following data table: 2 Ti = 0 0.2 0.4 0.6 f(x) = 2.018 2.104 2.306 0.2 and 23 = 0.4, the value obtained at 2=0.3 is Using Lagrange linear interpolation...

  • Need help with this question on matlab. Show code please! Salmon_dat.csv 272395 286156 391573 461443 401998...

    Need help with this question on matlab. Show code please! Salmon_dat.csv 272395 286156 391573 461443 401998 313120 240763 297488 446152 480276 420555 277697 357375 331788 420879 332479 320947 359853 300917 403286 416419 345028 256049 281980 286625 278560 344422 317956 219688 259337 208197 189419 272884 360673 248860 306981 401711 867728 870035 921314 846026 570413 493708 275954 518942 480284 809799 677171 589937 1129664 1152642 Exercise 1: Salmon Runs Download the file salmon-dat.csv included with the homework. This file con- tains the annual...

  • A group of physics students collected data from a test of the projectile motion problem that...

    A group of physics students collected data from a test of the projectile motion problem that was analyzed in a previous lab exercise (L5). In their test, the students varied the angle and initial velocity Vo at which the projectile was launched, and then measured the resulting time of flight (tright). Note that tright was the dependent variable, while and Vo were independent variables. The results are listed below. (degrees) Time of Flight (s) Initial Velocity V. (m/s) 15 20...

  • The first two parts should be solved by Matlab. This is from an intro to Numerical...

    The first two parts should be solved by Matlab. This is from an intro to Numerical Analysis Class and I have provided the Alog 3.2 in below. Please write the whole codes for me. Alog3.2 % NEWTONS INTERPOLATORY DIVIDED-DIFFERENCE FORMULA ALGORITHM 3.2 % To obtain the divided-difference coefficients of the % interpolatory polynomial P on the (n+1) distinct numbers x(0), % x(1), ..., x(n) for the function f: % INPUT: numbers x(0), x(1), ..., x(n); values f(x(0)), f(x(1)), % ...,...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

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