how to fix the error"Conversion to double from function_handle is not possible." for the code given below
Show older comments
n=input('Enter the number of points\n');
x=zeros(n,1);
f=zeros(n,1);
i=1;
j=1;
p=0;
l=zeros(n,1);
for i=1:n
x(i)=input('enter number\n');
end
for i=1:n
f(i)=input('Enter function value \n');
end
t=input('Enter the point whose function value is to be calculated\n');
for i=1:n
l(i)=1;
for j=1:n
if(i==j)
continue
end
syms y
l(i)=@(y)((y-x(j))/(x(i)-x(j)))*l(i);
end
p=p+l(i)*f(i);
end
fprintf('Value at given point is: %d',p(t))
Accepted Answer
More Answers (0)
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!