Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

TASK 3 OBJECTIVE: Write a function to do useful computation. You should work on

ID: 3726759 • Letter: T

Question

TASK 3 OBJECTIVE: Write a function to do useful computation. You should work on this task individually, but you may discuss results with your teammates. Write a function to perform linear interpolation between two points. Given coordinates Xyy,, x2,½ and a value x, find the corresponding y-value of the of the point on the line connecting the points (x,V,) and (x2.y2) y2 vi y1 x1 xi x2 Do error-checking for nonsensical input. Submit mvinterpolate.m to eCampus. Example >> myinterpolate (21 , 0.99802 , 26.7 , 0.99669 , 20.19) ans = 0.9982

Explanation / Answer

#function to perform linear interpolation between points

#Given co-ordinates x1,y1,x2,y2 and a value x

#finding y value of the point on the line

#connecting the points (x1,y1) and (x2,y2)

function [y] = myinterpolate (x1,y1,x2,y2,x)

y = y1 + (y2-y1)/(x2-x1) * (x-x1);
  
endfunction