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,9);
A(1,11)=A(2,10)-A(1,10);

P0=A(10,2);
h=A(2,1)-A(1,1);
T0=[1 -x(10)];
T1=conv(T0,[1 -x(9)]);
T2=conv(T1,[1 -x(8)]);
T3=conv(T2,[1 -x(7)]);
T4=conv(T3,[1 -x(6)]);
T5=conv(T4,[1 -x(5)]);
T6=conv(T5,[1 -x(4)]);
T7=conv(T6,[1 -x(3)]);
T8=conv(T7,[1 -x(2)]);
T9=conv(T8,[1 -x(1)]);

P1=A(9,3)*T0/h;
P2=A(8,4)*T1/(h*h*factorial(2));
P3=A(7,5)*T2/(h*h*h*factorial(3));
P4=A(6,6)*T3/(h*h*h*h*factorial(4));
P5=A(5,7)*T4/(h*h*h*h*h*factorial(5));
P6=A(4,8)*T5/(h*h*h*h*h*h*factorial(6));
P7=A(3,9)*T6/(h*h*h*h*h*h*h*factorial(7));
P8=A(2,10)*T7/(h*h*h*h*h*h*h*h*factorial(8));
P9=A(1,11)*T8/(h*h*h*h*h*h*h*h*h*factorial(9));

H0=[0 0 0 0 0 0 0 0 0 P0];
H1=[0 0 0 0 0 0 0 0 P1];
H2=[0 0 0 0 0 0 0 P2];
H3=[0 0 0 0 0 0 P3];
H4=[0 0 0 0 0 P4];
H5=[0 0 0 0 P5];
H6=[0 0 0 P6];
H7=[0 0 P7];
H8=[0 P8];
H9=[P9];

T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,P0,P1,P2,P3,P4,P4,P5,P6,P7,P8,P9,H0,H1,H2,H3,
H4,H5,H6,H7,H8,H9

Y=H0+H1+H2+H3+H4+H5+H6+H7+H8+H9;

Y
polyval(Y,x(1))
polyval(Y,x(2))
polyval(Y,x(3))
polyval(Y,x(4))
polyval(Y,x(5))
polyval(Y,x(6))
polyval(Y,x(7))
polyval(Y,x(8))
polyval(Y,x(9))
polyval(Y,x(10))

You might also like