how to fix the error"Conversion to double from function_handle is not possible." for the code given below
显示 更早的评论
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))
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!