Question: MATLAB Write a function [Y] = myLinearInterp(x, y, X) where the inputs x and y are (1 x n) double arrays containing experimental data points,

MATLAB

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. If X(i) is a value contained in x, then the Y(i) value should be the exact value contained in y that corresponds to the specified x value. You may not use interp1 or any built-in MATLAB function that does interpolation.

TEST CASE 1----------- >>

[Y] = myLinearInterp([0 2 5 8 10], [1 3 4 9 11], -1) Y = NaN

TEST CASE 2--------------- >>

[Y] = myLinearInterp([0 2 5 8 10], [1 3 4 9 11], 6) Y = 5.6667

TEST CASE 3---------------- >>

[Y] = myLinearInterp([0 2 5 8 10], [1 3 4 9 11], 11) Y = NaN

TEST CASE 4---------------- >>

[Y] = myLinearInterp([0 2 5 8 10], [1 3 4 9 11], [-0.5 0 7.4 9.99]) Y = NaN 1.0000 8.0000 10.9900

Please do not use any tools not included in the basic student MATLAB package

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!