Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function [Y] = myLinearInterp(x, y, X) where the inputs x and y are (1 x n) double arrays containing experimental data points, and
Write a function [Y] = myLinearInterp(x, y, X) where the inputs x and y are (1 x n) double arrays containing experimental data points, and X is a (1 x m) double array. Use Matlab
Problem 2: Write your Interpolation Function Write a function [Y] -myLinearInterp (x, y, X) where the inputs x and y are (1 x n) double arrays containing experimental data points, and X is a (1 x m) double array. You may assume that x and y are in ascending order and have unique elements. The output argument, Y, should be a (1 x m) vector where Y(i) is the linear interpolation of X(i). IMPORTANT: The Y(i) value should be NaN if a X(i) value is outside the range of values in x. IfX(i) is a value contained in x, then the Y(i) value should be the exact value contained iin y that corresponds to the specified x value. You may not use interpI or any built-in MATLAB function that does interpolation. TEST CASE 1 >> [Y] = myLinea r Interp ([0 2 5 8 10], [1 3 4 9 11], -1) NaN TEST CASE 2 >> [Y] = myLinea r interp ([0 2 5 8 10], [1 3 4 9 11], 6) 5.6667 TEST CASE 3 >> [Y] = myLinea r Interp ([0 2 5 8 10], [1 3 4 9 11], 11) NaN TEST CASE 4 >> [Y] = myLinea r Interp ([0 2 5 8 10], [1 3 4 9 11], [-0.5 0 7.4 9.99]) NaN 1.0000 8.0000 10.9900
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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