Check for missing argument or incorrect argument data type in call to function 'diff'. How to solve the issue? Please help.
이전 댓글 표시
a=input('Enter the function in the form of variable x:','s');
x(1)=input('Enter Initial Guess:');
error=input('Enter allowed Error:');
f=inline(a)
syms x;
dif=diff(f);
d=inline(dif);
for i=1:100
x(i+1)=x(i)-((f(x(i))/d(x(i))));
err(i)=abs((x(i+1)-x(i))/x(i));
if err(i)<error
break
end
end
root=x(i)
답변 (1개)
Steven Lord
2020년 9월 30일
0 개 추천
The inline function is not recommended. If you were writing a function to be evaluated in MATLAB, you should create an anonymous function (either by typing it explicitly or using str2func.) But since you want to create a symbolic object use the str2sym function instead.
카테고리
도움말 센터 및 File Exchange에서 Newton-Raphson Method에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!