Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a MATLAB function that accepts as input a set of {xi, yi} data and a desired x value, and returns the corresponding y
Write a MATLAB function that accepts as input a set of {xi, yi} data and a desired x value, and returns the corresponding y value by performing linear interpolation. Your function should be able to be used with the following format: yinterpolated = yourfunctionname (x, y, xgoal); x is a vector of x values, y is a vector of y values, and the function should return the value y(xgoal). You should write the algorithm for your function yourself. Do not use a built-in MATLAB function for linear interpolation. Your function should NOT display anything to the screen. You may make the following assumptions about the inputs to the function. The inputs x and y are vectors of the same length. The length of x and y is at least 2. The x values are already sorted from smallest to largest values. xgoal is a scalar (single valued) number, and it falls between the smallest and largest values of the values in the vector x.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
MATLAB function that performs linear interpolation function ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started