Enter in Matlab a list of 5-15 values from a table in an engineering textbook st
ID: 3184263 • Letter: E
Question
Enter in Matlab a list of 5-15 values from a table in an engineering textbook state your source and what the values represent). Give Matlab code that, in separate graphs, plots the (a) polynomial interpolation and (b cubic spline interpolation through the given values. (c) Describe how the two interpolating curves differ visually, and relate these differences to the characteristics of the two kinds of interpolating functions. Based on your physical knowledge of what the values represent, which interpolating function do you consider more accurate?Explanation / Answer
%%%MATLAB CODE
%%define some variable according to your data
step= ;%stepsize for horizontal axis (x-axis)
x1max= ;% maximum value of x1 you want to take
%%enter data
x=input();
y=input();
x1=linespace(0,step,x1max);
p=polyfit(x,y,n); %%n is the degree of polynomial you want
y1=polyval(p,x1); %%values of y1 at x1 interpolated by the polynomial function p
y2=spline(x,y,x1);
%% a) part
figure
plot(x1,y1)
xlabel(' Horizontal axis data'); %Whatever the horizontal axis represent
ylabel('Vertical axis data'); %Whatever the vertical axis represent
title('Polynomial Interpolation of the data');
%%b) part
figure
plot(x1,y2)
xlabel('Horizontal axis data'); %Whatever the horizontal axis represent
ylabel('Vertical axis data'); %Whatever the vertical axis represent
title('Cubic Spline Interpolation of the data');
%%%%%%
Explanation
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.