Inline ; use anonymous functions instead.
조회 수: 5 (최근 30일)
이전 댓글 표시
obviously, I an not a programmer. I saw this code for newton raphson method (for schoolwork), but when i tried to run it, it said that Ishould use an anonymous functions instead. what should i do?
clear , clc
cf=input('ingrese funcion a evaluar: ');
syms x
f=inline(cf);
derivada=diff(cf,x);
df=inline(derivada);
tol = input('ingrese tolerancia: ');
error = 50;
x=input('ingrese un valor inicial: ');
n =0;
disp(' n xi error')
while (error>tol)
fprintf('\t%i\t%3.5f\t%f\n', n, x, error);
n=n+1;
x=x-f(x)/df(x);
error= abs(f(x));
end
댓글 수: 2
Stephen23
2018년 11월 21일
"what should i do?"
Read the help on anonymous functions, practice a little bit, and then use one in your code.
채택된 답변
madhan ravi
2018년 11월 21일
편집: madhan ravi
2018년 11월 21일
cf=input('ingrese funcion a evaluar: ','s');
derivada=diff(str2sym(cf),x); %change this line too
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!