Question

interp1, polyfit, polyval, diff, trap, quad 1 INTERPOLATION (2 PTS) You did an experiment and obtained the following data set
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

close all
clear
clc

x = 10:10:100;
y = [23 45 60 82 111 140 167 198 200 220];

fprintf('Part 1\n---------------------------------------------------\n')
fprintf('Result: %f\n', interp1(x,y,15,'linear'))

fprintf('\nPart 2\n---------------------------------------------------\n')
fprintf('Result: %f\n', interp1(x,y,15,'spline'))

fprintf('\nPart 3\n---------------------------------------------------\n')
fprintf('Result: %f\n', interp1(y,x,80,'linear'))

xx = 10:2:100;
yy = interp1(x,y,xx,'spline');
plot(x,y,'ro',xx,yy,'b--')
xlabel('x'), ylabel('y')
legend('Data Points', 'Interpolated Curve', 'Location', 'northwest')
title('Part (4)')

Output:

Part 1
---------------------------------------------------
Result: 34.000000

Part 2
---------------------------------------------------
Result: 35.954676

Part 3
---------------------------------------------------
Result: 39.090909

Plot:

Part (4) 220 O Data Points 200 -_- Interpolated Curve 180 160 140 120 100 80 60 40 F 20叱 10 20 30 40506070 80 90 100

Add a comment
Know the answer?
Add Answer to:
interp1, polyfit, polyval, diff, trap, quad 1 INTERPOLATION (2 PTS) You did an experiment and obtained the followin...
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
  • 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...

  • N MATLAB: This is an easy problem to demonstrate how polyfit and polyval work! The values...

    N MATLAB: This is an easy problem to demonstrate how polyfit and polyval work! The values in y are basically a sine function on x. You can validate by checking in MATLAB >> x = 0:9 x = 0 1 2 3 4 5 6 7 8 9 >> y = sin(x) y = 0 0.8415 0.9093 0.1411 -0.7568 -0.9589 -0.2794 0.6570 0.9894 0.4121 Now, let us try to see what happens if we use polyfit on the values of...

  • 2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1...

    2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1 | 0.15 | 0.2 | 0.3 | 0.35 | 0.5 | 0.75 yi 4.0 1.0 1.22.12.02.52.5 For all tasks below, please submit your MATLAB code and your plots. You can write all code in a single (a) Using MATLAB, plot the interpolating (6th degree) polynomial given these data on the domain .m-file [0.1,0.75] using the polyfit and polyval commands. To learn how to use...

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

    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 known mathematical function. The same function can then be used to compute true values at the interpolated points to use in error Consider the following mathematical function (Runge's function): 1+25r2 Write a function mfile that uses this formula to generate a set of data use those points along approaches outlined...

  • Consider the function f(x) 1 25x which is used to test various interpolation methods. For the rem...

    Consider the function f(x) 1 25x which is used to test various interpolation methods. For the remainder of this problem consider only the interval [-1, 1] The x-values for the knots (or base-points) of the interpolation algorithm are located at x--1,-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75 1. (a) Create a "single" figure in Matlab that contains 6 subplots (2x3) and is labelled as figure (777), i.e the figure number is 777. Plot in each subplot the function f(x) using...

  • 1. Consider the Runge function, f:IH 1/1+25r). (a) Use your Lagrange interpolation code (from the...

    1. Consider the Runge function, f:IH 1/1+25r). (a) Use your Lagrange interpolation code (from the previous worksheets) to approximate f using 10, 20, 30, and 40 equispaced points from -1 and 1 (inclusive). Make a (single) plot comparing these four approximations with the (exact) function f. Use a legend to help distinguish the five curves. Intuitively, increasing the number of sample points should give a 'better' approximation. Does it? (A qualitative answer is sufficient.) (b) Repeat Part (a) using piecewise...

  • Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)d...

    help wanted?? thank you explain correctly Problem 1 Use the trapezoidal rule technique to approximate the following integrals: a) 「(x2+1)dr(Note: use 0.5 increments forx) b) sina d INote: use a MATLAB function to subdivide the interval into eight equal parts) c e dx (Note: use 0.25 increments for x Problem 2 Use the Simpson's rule to evaluate the following integrals aDdr Problem 3: Given the polynomial: x3-6x2 + 30-0, Use MATLAB to find all roots of this polynomial. Use MATLAB's...

  • I'm not allowed to use polyfit or polyval functions. The hint the homework gives is setting...

    I'm not allowed to use polyfit or polyval functions. The hint the homework gives is setting up a linear system for the polynomial coefficients and solving it. The test case x = [1,2,3,4] y = [5,-2,3,0] x_dot = [1.5,2.5] should result in y_dot = -1.2500 0.2500 p = -3.333 26.0000 -61.6667 44.0000 Thanks to anyone who can answer this within the next day or so! 1 Interpolation methods 1.1 The Lagrange polynomial function (y dot,p] = my Lagrange (x, y,x_dot)...

  • And Data 2 and the two fitted lines over the range o 3.3 Plot on the same groph Data 3.4 Find the...

    please use MATlab and answer in 15 minutes and Data 2 and the two fitted lines over the range o 3.3 Plot on the same groph Data 3.4 Find the value of x at which the two fitted lines are equal Dr Test ".il 39%)[13:43 PM VIVA Di Answer 1 of1 %Straight line, Y-MX + C X1 -0.2:0.6.2; Y1 [60 350 700 900] P1- polyfit(X1, Y1,1); YP1 polyval(P1, X1); M1 P1 (1) C1 P1(2) plot(X1, Y1 , 'ro', X1, YPI...

  • When images are scaled or resized, the values between pixels need to be guessed/interpolated in o...

    Whats wrong with my code? Please use MATLAB and can you answer the questions too. When images are scaled or resized, the values between pixels need to be guessed/interpolated in order to fill in the missing gaps. Write a function that takes a grayscale image (pick your own image) and a scaling factor (any positive decimal value) as input and resizes the image using the following methods; a) Nearest neighbouring pixel b) Linear interpolation (in x-direction first, then y-direction) c)...

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