Question: using matlab code language don't use java or c Create a function with the header: function [Y] = myinterpfunction(x,y,X,method) Where x and y are column

using matlab code language don't use java or c

Create a function with the header:

function [Y] = myinterpfunction(x,y,X,method)

Where x and y are column vectors containing experimental data points, and X is an array. Assume that x and X are in ascending order and have unique elements. The output argument, Y, should be a vector, the same size as X, where Y(i) is the interpolation of X(i) using the method specified.

The options for method should be

linear : uses linear interpolation

spline : uses cubic spline interpolation

nearest : uses nearest neighbor interpolation

Hint1: you should use the function strcmp to compare the given method to the different options. If the output of strcmp is = 1, then the two strings are the same.

Example: if strcmp(method, linear) == 1 %the method is linear

Hint2: for the spline method, you may want to start with a matrix of zeros sized 4(n-1) x 4(n-1) - you can use the zeros(rows, columns) function for this

Your function should plot the data points (x,y) as open circles and should plot the interpolation as a black line. Be sure to include a title, legend, and axis labels.

x = [0 0.1 0.15 0.35 0.6 0.7 0.95 1];

y = [1 0.8187 0.7408 0.4966 0.3012 0.2466 0.1496 0.1353];

X = linspace(0,1,100);

[Y] = myinterpfunction(x,y,X, nearest)

-don't use a built in function interp1

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!