Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

T-Mobile 6:17 PM * 29% LO. I need help in matlab for this exercise, I got part a

ID: 3735721 • Letter: T

Question

T-Mobile 6:17 PM * 29% LO. I need help in matlab for this exercise, I got part a already but I need help with part b (3rd order Lagrange poly) I don't know how to do that in matlab. Thanks 2. In the table below, (a) integrate by first interpolating the data using a 6th order polynomial using the polyfit function of MATLAB and (b) using 3rd order Lagrange polynomials (ALSO IN MATLAB). Since we are working with data, and not an analytical function, there is no way to know the exact solution. However, which method do you think is more accurate (a or b)? Create three plots. On each graph, plot either the Placebo, IV or Intrathecal data along with their 6th order polynomial fit and the fit using the Lagrange polynomials. For the 6th degree and Lagrange polynomials, plot 101 points between t-0 and t-10. Be sure to properly label the axis. Hours Placebo Intravenous Intrathecal 4 0 35 3.5 16 16 13.5 10 5.5 35 4.5 7.5 10

Explanation / Answer

Part b)

3rd order lagrange polynomial code

=================

hr=[0 1 2 4 6 8 10]; %hours
plc=[38 35 42 35.5 35 34.5 37.5]; %placebo
X=hr(1:4); %selecting 4 data points
Y=plc(1:4);
    syms x;
    l=x*zeros(1,1);
    n=length(X);
    for i=1:n
        xt=X;
        x0=xt(i);
        xt(i)=[];
        ln=1;
        ld=1;
        for j=1:n-1
            ln=ln*(x-xt(j));
            ld=ld*(x0-xt(j));
        end
        l(i)=ln/ld;
    end
    p=l*Y'; %3rd order langrange polynomial
plc_lang=subs(p,hr);
plot(hr,plc_lang)

===============