Check for missing argument or incorrect argument data type in call to function 'diff'. How to solve the issue? Please help.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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)
0 Commenti
Risposte (1)
Steven Lord
il 30 Set 2020
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.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!