Find the polynomial interpolant that passes through the 7 given data points usin
ID: 3209685 • Letter: F
Question
Find the polynomial interpolant that passes through the 7 given data points using matlab commands. there is no need to display the polynomial expression. Calculate the length of the polynomial interpolant using matlab. Display the length of the curve using the fprintf statement.
This is where my matlab code starts!!!
x=[ -4, -1.375, -0.8, 0, 1, 1.8, 3.375];
y=[ 0, 3, 4, 4.4375, 3.75, 2, 0];
n=length(x);
sum=0;
poly=polyfit(x,y,n-1);
dpoly=diff(poly);
dpoly2=dpoly.^2;
a=x(1);
b=x(length(n));
s=int(sqrt(1+dpoly2));
disp(s)
Explanation / Answer
%%% Matlab code %%%%
clc;
clear all;
close all;
format long
format compact;
x=[-4,-1.375,-0.8,0,1,1.8,3.375];
y=[0 3 4 4.4375 3.75 2 0];
a=min(x);
b=max(x);
n=length(x);
p=polyfit(x,y,n-1);
syms x
sum=0;
for k=1:length(p)
sum=sum+x^(length(p)-k)*p(k);
end
f=sum; %%% function to be differentiated
length=int(sqrt(1+diff(f)^2),a,b);
fprintf('Length of curve = %f ',length);
OUTPUT:
Length of curve = 20.221912
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.