Subscript indices must either be real positive integers or logicals.

조회 수: 1 (최근 30일)
Corey Nehoda
Corey Nehoda 2016년 11월 14일
답변: Alexandra Harkai 2016년 11월 14일
I am attempting to write a code for 6th order Newton's Interpolation. I am getting the error stated above and I'm not quite sure how to fix it. Here is my code so far.
% data
x=[0, 1.8,5, 6, 8.2, 9.2, 12];
y=[26, 16.415, 5.375, 3.5, 2.015, 2.54, 8];
X=input('x value=')
% divided differences
f1= (y(2)-y(1))/(x(2)-x(1));
f2= (y(3)-y(2))/(x(3)-x(2));
f3= (y(4)-y(3))/(x(4)-x(3));
f4= (y(5)-y(4))/(x(5)-x(4));
f5= (y(6)-y(5))/(x(6)-x(5));
f6= (y(7)-y(6))/(x(7)-x(6));
b0= y(1);
b1= f1;
b2= (f2-f1)/(x(3)-x(1));
b3= ((f3-f2/x(3)-x(2))-b2)/(x(4)-x(1));
b4=(((f4-f3)/x(4)-x(3))-b3)/(x(5)-x(1));
b5=(((f5-f4)/x(6)-x(5))-b4)/(x(6)-x(1));
b6=(((f6-f5)/x(7)-x(6))-b5)/(x(7)-x(1));
% Formula
F=b0+b1*(X-x(1))+b2*(X-x(1))*(X-x(2))+b3(X-x(1))*(X-x(2))*(X-x(3))+b4*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))+b5*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))+b6*(X-x(1))*(X-x(2))*(X-x(3))*(X-x(4))*(X-x(5))*(X-x(6));
answer=F

답변 (1개)

Alexandra Harkai
Alexandra Harkai 2016년 11월 14일
F= ... b3(X-x(1)) ...
A '*' is missing:
F= ... b3*(X-x(1))...

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by